在我的應用我想與像用戶ID發送參數的JSONObject,任何人都可以請建議我從那裏我可以採取一些幫助一些教程...發送JSON對象與參數
我得到這個代碼,但在這代碼我只能夠發送的JSONObject不是參數..
我的網址是這樣的:http://www.example.com/JSONObject/userId
我如何可以傳遞的JSONObject與用戶id到服務器..
public class HTTPPoster {
public HttpResponse doPost(String url, JSONObject jsonProfilo) throws ClientProtocolException, IOException {
DefaultHttpClient httpclient = new DefaultHttpClient();
HttpPost request = new HttpPost(url);
HttpEntity entity;
StringEntity s = new StringEntity(jsonProfilo.toString());
s.setContentEncoding((Header) new BasicHeader(HTTP.CONTENT_TYPE, "application/json"));
entity = s;
request.setEntity(entity);
HttpResponse response;
response = httpclient.execute(request);
return response;
}
}
謝謝..
就會把我的用戶id中的JSONObject做的工作?因爲我的URL是這樣的:www.example.com/api/JSONObject/userId – 2013-02-19 09:34:54
ofcourse u可以保留用戶ID和其他細節在你的JSON ....它將完美工作 – user1969053 2013-02-19 09:38:35
我有一個字與我的PHP開發人員,他說我需要userId獨立作爲一個字符串不在jsonobject – 2013-02-19 09:41:12