Tuesday, December 20, 2016

json_decode(file_get_contents("php://input") on https

When you try to run json_decode on https, it will throw errors due to null value. file_get_contents("php://input") will also return null.

Way to solve it and the most efficient are as follows

//get data from caller
$your_data_array= json_decode(file_get_contents("php://input",false, stream_context_create($arrContextOptions)),true);

The code actually make it don't care what protocol you are using and set it to false (means no verifications). It normally happen when you are using self-signed or non-standard SSL certificates.

It is the most efficient and the fastest solutions.. but not the most practical :)

The best is -> use standard approved certificates :)


Mahesh P said...

Nice Information thank you for Sharing useful information. Great job.
App developer Malaysia

prem said...

Thanks for an insightful post.These tips are really helpful. Thanks a lot.Keep it up.Keep blogging.!!
app developer malaysia!

Share It

Popular Posts