I am working with an API allows me to send a text message to a particular number it will then post that text info to my server as a JSON response. It has me configure the call back url and it is posting something to it. This is what I am being told the call looks like:
POST /business/getSMS HTTP/1.1
x-hookmobile-message-id: 297173743
User-Agent: Jakarta Commons-HttpClient/3.1
Host: testing.com
Content-Length: 152
Content-Type: text/plain; charset=UTF-8
{
"timestamp":"Fri Jan 18 21:56:32 GMT 2013",
"text":"Test",
"from":"+11111111111",
"messageId":"297173743",
"type":"incomingSms",
"recipient":"+11111111111"
}
What I am having trouble figuring out is how in PHP I can grab the JSON response. I tried $_POST just to see if the posted data is there but I don’t get anything. This is the first time I have done this so I am at a bit of a loss here. How do I grab the posted json?
You’ll have to read the raw post data.