私のアプリケーションでは、UserIdなどのパラメーターを使用してJSONObjectを送信しようとしています。誰かが私にいくつかのチュートリアルを提案してくれますか?
このコードを取得しましたが、このコードでは、パラメーターではなくJSONObjectのみを送信できます。
私のURLは次のようなものです:http://www.example.com/JSONObject/userId
userIdを持つJSONObjectをサーバーに渡すにはどうすればよいですか。
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;
}
}
ありがとう..