-3
    https://fcm.googleapis.com/fcm/send     
    Content-Type:application/json
   Authorization:key=AIzaSyZ-1u...0GBYzPu7Udno5aA
   { "data": {
     "score": "5x1",
         "time": "15:10"   },  
        "to" : "bk3RNwTe3H0:CI2k_HHwgIpoDKCIZvvDMExUdFQ3P1..." }

how to use httppost to send this json to the url direclty from android app

  • There are either too many possible answers, or good answers would be too long for this format. Please add details to narrow the answer set or to isolate an issue that can be answered in a few paragraphs. – Gustavo Morales Jun 13 '16 at 13:56
  • i want to send this data to firebase server so that it can send it to particular device.Orignal method of doing that is from your app server,but i want to directly send data to firebase server from app.so tell me how to put data exactly in this format and send all data at once to server – Gagan deep Jun 13 '16 at 15:22

1 Answers1

0

You need to format and parse your JSON, for example into a List of String or HashMap. Then use an AsyncTask to create an HTTP request (with POST). Check this link Sending HTTP Post Request with Android and into the NameValuePair.add() pass you list of strings, that represent the JSON you want to send.

Into the value:

 HttpResponse response = httpclient.execute(httppost);

you have the result of your HTTP POST requeste (for example a String or another json).

Community
  • 1
  • 1
rik194
  • 98
  • 1
  • 11