Skip to content

Instantly share code, notes, and snippets.

@guilhermecarvalhocarneiro
Created March 11, 2014 01:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save guilhermecarvalhocarneiro/9477764 to your computer and use it in GitHub Desktop.
Save guilhermecarvalhocarneiro/9477764 to your computer and use it in GitHub Desktop.
JSONObject jsonobj; // declared locally so that it destroys after serving its purpose
jsonobj = new JSONObject();
JSONObject header = new JSONObject();
jsonobj.put("nome", "Guilherme");
jsonobj.put("pais", "Brasil");
jsonobj.put("chave", regIdGCMService.toString());
jsonobj.put("Authorization", "Token 0d0c898a1c26235f25f256ed853c9a09f3dce8bd");
DefaultHttpClient httpclient = new DefaultHttpClient();
HttpPost httppostreq = new HttpPost(wurl);
StringEntity se = new StringEntity(jsonobj.toString());
Log.i("JSONObject", jsonobj.toString());
se.setContentType("application/json;charset=UTF-8");
se.setContentEncoding(new BasicHeader(HTTP.CONTENT_TYPE, "application/json;charset=UTF-8"));
httppostreq.setEntity(se);
HttpResponse httpresponse = httpclient.execute(httppostreq);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment