Answer the question
In order to leave comments, you need to log in
How can I accept a POST request from an Android app?
A post request has been written for the client, how to make the server part?
What php or mysql files are needed and how to prescribe in general so that there is a text output in black and white at the request link on the hosting?
Thank you in advance for your help
{
Log.d("MYLOGS", "doInBackground " + MainActivity.this.msgData);
paramVarArgs = new DefaultHttpClient();
HttpPost localHttpPost = new HttpPost("http://google.php");
localHttpPost.setHeader("Content-Type", "application/x-www-form-urlencoded;charset=UTF-8");
try
{
ArrayList localArrayList = new ArrayList();
localArrayList.add(new BasicNameValuePair("msgs", MainActivity.this.msgData));
localHttpPost.setEntity(new UrlEncodedFormEntity(localArrayList, "UTF-8"));
paramVarArgs = paramVarArgs.execute(localHttpPost);
Log.d("MYLOGS", "response " + EntityUtils.toString(paramVarArgs.getEntity()));
return null;
}
catch (IOException paramVarArgs)
{
for (;;) {}
}
catch (ClientProtocolException paramVarArgs)
{
for (;;) {}
}
}
Answer the question
In order to leave comments, you need to log in
It seems that you can't explain it in a nutshell ... At a minimum, you need an HTTP server that will process your requests. For development, you can use some XAMPP locally. Well, then, read how it works in conjunction, I mean HTTP server + PHP + MySQL.
I'm not strong in Android development, but I think you can cover such a code with a test in which to emulate a response from the server.
I'm not strong in web development, but when android communicates with the server, then the php file (for example index.php) should probably just read the global POST variable ( $var = $_POST['NAME'] ) and then you can do everything with $var anything, and send it to the database (if the password from the database and everything else is accepted in the same way before that) ... this topic is also interesting to me, but so far I haven’t figured it out, the options will be interesting
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question