-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

2
  • 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. Commented Jun 13, 2016 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 Commented Jun 13, 2016 at 15:22

1 Answer 1

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).

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.