你好人我试图把我的JSONArray发送到PHP页面 我得到HTTP // 1.1 200,但我仍然无法显示它在我的PHP页面,我仍然没有知道我必须成功,这里给它或不 是我的Android代码Android - 发送JSONArray到php
public void sendJson() {
HttpClient client = new DefaultHttpClient();
HttpConnectionParams.setConnectionTimeout(client.getParams(), 10000); //Timeout Limit
HttpResponse response;
try{
HttpPost post = new HttpPost("http://sap-sp-test.dff.jp/sp.php/ranking/index");
Log.i("entry", MixiActivity.entry.toString());
ArrayList<NameValuePair> nVP = new ArrayList<NameValuePair>(2);
nVP.add(new BasicNameValuePair("json", MixiActivity.entry.toString()));
post.setEntity(new UrlEncodedFormEntity(nVP));
response = client.execute(post);
Log.i("postData", response.getStatusLine().toString());
}
catch(Exception e){
e.printStackTrace();
Log.i("error", e.getMessage());
}
}
PHP代码
$data = $_POST['json'];
echo $data;
我已经尝试了一些例子在这里,但我仍然无法发送的数据 和JSON数组(MixiActivity.entry)不为空 ,当我尝试使用日志打印,日志显示JSON阵列 权价值,但我不能将其发送到PHP 请帮我解决这个问题
非常感谢
尼科
确定我会尝试它感谢mariachi!我会告诉你结果 – 2012-07-23 09:43:14
对不起mariachi我已经尝试过但我仍然不能发布JSON数组任何其他想法? – 2012-07-23 10:17:27
你对response.getStatusLine()。toString()的回应是什么,你试过我的哪一个建议? – 2012-07-23 10:36:37