我有送价值从机器人到PHP和HttpPost 但我得到响应“请求的URL不能被检索”请求url无法检索?
这是我的代码
try {
HttpClient client = new DefaultHttpClient();
HttpPost post = new HttpPost(link);
post.setEntity(new UrlEncodedFormEntity(sendValue));
HttpResponse response = client.execute(post);
Toast.makeText(this, response.getStatusLine().toString(),
Toast.LENGTH_LONG).show();
if (response.getStatusLine().toString().contains("200")) {
Toast.makeText(this, "Komentar berhasil dibuat",
Toast.LENGTH_LONG).show();
finish();
}
else{
Toast.makeText(this, "Koneksi server bermasalah",
Toast.LENGTH_LONG).show();
}
} catch (Exception e) {
Log.e("log_tag", "Error connection" + e.toString());
}
,但如果我删除“post.setEntity(新UrlEncodedFormEntity(sendValue));” 我可以连接到PHP文件..
如何解决这个问题?
编辑
我已成立这样
private List<NameValuePair> sendValue = new ArrayList<NameValuePair>(4);
sendValue.add(new BasicNameValuePair("link", urlShare.toString()));
sendValue.add(new BasicNameValuePair("message", postComment.getText().toString()));
sendValue.add(new BasicNameValuePair("name", nameText.getText().toString()));
sendValue.add(new BasicNameValuePair("email", emailText.getText().toString()));
什么是'sendValue'设置? – 2011-03-22 12:14:32
您是否在清单文件中设置了网络权限? – Olegas 2011-03-22 13:45:01
是的,我已设置权限访问互联网在清单文件.. – pensilhijau 2011-03-22 15:01:25