fork download
  1. public static void postData() {
  2.  
  3. new Thread(new Runnable() {
  4.  
  5. @Override
  6. public void run() {
  7.  
  8. // Create a new HttpClient and Post Header
  9. HttpClient httpclient = new DefaultHttpClient();
  10. HttpPost httppost = new HttpPost(
  11. "https://a...content-available-to-author-only...s.com/gcm/send");
  12. httppost.addHeader("Authorization", "key="
  13. + CommonUtilities.GOOGLE_API_KEY);
  14. httppost.addHeader("Content-Type", "application/json");
  15.  
  16. try {
  17. // Add your data
  18. List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(
  19. 2);
  20. nameValuePairs.add(new BasicNameValuePair(
  21. "registration_ids", CommonUtilities.tempID));
  22. nameValuePairs.add(new BasicNameValuePair("data",
  23. "test send"));
  24. httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
  25.  
  26. // Execute HTTP Post Request
  27. HttpResponse response = httpclient.execute(httppost);
  28.  
  29. } catch (ClientProtocolException e) {
  30. } catch (IOException e) {
  31. }
  32. }
  33. }).start();
  34. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:1: error: class, interface, or enum expected
public static void postData() {
              ^
Main.java:6: error: class, interface, or enum expected
			public void run() {
			       ^
Main.java:10: error: class, interface, or enum expected
				HttpPost httppost = new HttpPost(
				^
Main.java:12: error: class, interface, or enum expected
				httppost.addHeader("Authorization", "key="
				^
Main.java:14: error: class, interface, or enum expected
				httppost.addHeader("Content-Type", "application/json");
				^
Main.java:16: error: class, interface, or enum expected
				try {
				^
Main.java:20: error: class, interface, or enum expected
					nameValuePairs.add(new BasicNameValuePair(
					^
Main.java:22: error: class, interface, or enum expected
					nameValuePairs.add(new BasicNameValuePair("data",
					^
Main.java:24: error: class, interface, or enum expected
					httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
					^
Main.java:27: error: class, interface, or enum expected
					HttpResponse response = httpclient.execute(httppost);
					^
Main.java:29: error: class, interface, or enum expected
				} catch (ClientProtocolException e) {
				^
Main.java:34: error: class, interface, or enum expected
	}
	^
12 errors
stdout
Standard output is empty