this is my code.
public void sendMessage1(PrintWriter out,String access_token,String
message,String key) {
DefaultHttpClient client = new DefaultHttpClient();
HttpPost post = new HttpPost(authUrl);
post.addHeader("Authorization","Bearer "+ access_token);
ArrayList<BasicNameValuePair> paramList = new
ArrayList<BasicNameValuePair>();
paramList.add(new BasicNameValuePair("registration_id", regId));
paramList.add(new BasicNameValuePair("collapse_key", key));
paramList.add(new BasicNameValuePair("data."+"message", message));
try {
post.setEntity(new UrlEncodedFormEntity(paramList, HTTP.UTF_8));
HttpResponse response = client.execute(post);
out.print(EntityUtils.toString(response.getEntity()));
} catch (UnsupportedEncodingException e) {
throw new C2DMException(e);
} catch (ClientProtocolException e) {
throw new C2DMException(e);
} catch (IOException e) {
throw new C2DMException(e);
}
}
Hope this helps.