Reputation: 49
Folks I think I may miss a dead simple thing but I just have no idea where to look for it.
So I'm trying to implement block.io API to accept bitcoin payments on a website built on PHP. Now the Docs say that all notification events will use JSON objects pushed to my server through POST requests. So I decided to make a test BTC payment and log all requests on a specified URL to my DB. And here what I gen on dumping getallheaders()
{
["Content-Type"]=>
string(16) "application/json"
["User-Agent"]=>
string(12) "Block.io/0.1"
["Accept"]=>
string(10) "text/plain"
["Authorization"]=>
string(10) "Basic Og=="
["Connection"]=>
string(5) "close"
["Host"]=>
string(17) "site.com"
["Content-Length"]=>
string(3) "462" }
But dumping $_POST
gives me an empty array. Dumping $_SERVER
and $_GET
gives nothing useful either.
So my question is how can I find the JSON string declared in Content-Type?
Any suggestion would be helpful! Thanks!
Upvotes: 1
Views: 72
Reputation: 864
Because the Content-Type is application/json
(not application/x-www-form-urlencoded
)
$inputJSON = file_get_contents('php://input');
EDIT: excellent explanation at PHP "php://input" vs $_POST
Upvotes: 1