开发者

How can I send an array of arrays with android's httppost

I would like to send an a开发者_开发百科rray of arrays from an android phone to a server. Is there any possibility to do this?

I expect something like this at the server side:

$_POST['items'] = array(
    array('name'=>'joe', 'email'=>'joe@example.com'), 
    array('name'=>'jane', 'email'=>'jane@example.com')
);

Thx for your help!


Use HttpPost to send data to the server, and use json to create an array of array's. nameValuePairs will carry the data:

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);

Hope this helps...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜