我想从Android手机向服务器发送一组数组。有可能这样做吗?
我希望服务器端有这样的东西:
$_POST['items'] = array(
array('name'=>'joe', 'email'=>'joe@example.com'),
array('name'=>'jane', 'email'=>'jane@example.com')
);
谢谢你的帮助!
答案 0 :(得分:0)
使用HttpPost
将数据发送到服务器,并使用json
创建阵列数组。 nameValuePairs
将传输数据:
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://www.yoursite.com");
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(1);
nameValuePairs.add(new BasicNameValuePair("items", jsonObject));
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
HttpResponse response = httpclient.execute(httppost);
希望这会有所帮助......