My question is: How to call a php with HttpPost?
final HttpClient httpclient = new DefaultHttpClient();
final HttpPost httppost = new HttpPost("www.example.de/mySkript.php");
final ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
nameValuePairs.add(new BasicNameValuePair("param1", "value1"));
nameValuePairs.add(new BasicNameValuePair("param2", "value2"));
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
final HttpResponse response = httpclient.execute(httppost);
We found this...but we don't want to send Parameters/Values to the PHP because our PHP is counting +1 if you call it through the URL. Any code for just call the PHP?
Thank you :)
edit: The PHP is:
<?php
$userdatei = fopen ("test.txt","r");
$zeile = fgets($userdatei, 500);
$zeile++;
fclose($userdatei);
$schreiben = fopen ("test.txt","w");
fwrite($schreiben, $zeile);
fclose($schreiben);
?>
And Use this Code:
public static HttpResponse hitUrl(String url) {
try {
HttpClient httpclient = new DefaultHttpClient();
HttpResponse response = httpclient.execute(new HttpGet(url));
return response;
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
And call it with:
hitUrl("http://example.de/test.php");
Is this right?