我想通过下面的代码使用HttpPost发送数据到我的服务器。Android HttpPost数据
private boolean FacebookLogin(String url) {
boolean isDataSend = false;
try {
HttpClient client = new DefaultHttpClient();
HttpPost request = new HttpPost(url);
List<NameValuePair> value = new ArrayList<NameValuePair>();
value.add(new BasicNameValuePair("data", FacebookData()));
UrlEncodedFormEntity entity = new UrlEncodedFormEntity(value);
request.setEntity(entity);
HttpResponse res = client.execute(request);
if (res.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
String bufstring = EntityUtils.toString(res.getEntity(),
"UTF-8");
isDataSend = true;
}
} catch (Exception e) {
}
return isDataSend;
}
有没有什么办法可以看看$ _POST在服务器端看起来如何。这样我就可以更容易地编码服务器部分。
你能分享我的代码吗? –
file_put_contents('test-output.txt',$ output = print_r($ _ POST,true)); – fonini
非常感谢fonini –