Thursday, 8 August 2013

How do I use received JSON with PHP

How do I use received JSON with PHP

I'm reading an integration API and it says it will send requests in this
format:
content-type: application/json
accept: application/json
x-gsc-api-key: lRDs8NfsVTmHD8SC1234
{
"name" : "testuser",
"password" : "098f6bcd4621d373cade4e832627b4f6",
"reference" : "b86de61-af20-4c47-af9a-6f2edeebc4fe"
}
I want to server the requests with PHP. I know some other posts also ask
something along the same lines, but they were sending the request via AJAX
method. I don't know which method the request is going to be sent.
Can I just reference the variables $_POST['name'] and $_POST['password']
to get the values? Or do I need to call json_decode($_POST)?
Is this information enough the write a PHP script that server the request?
Any help would be appreciated.

No comments:

Post a Comment