How to make file_get_contents('php://input') to support for http and https, so that any request either from http or https can get processed without any trouble?
On server I have added redirection to redirect user from http to https. Currently our website apps are pointed to HTTP and the next version of app will be connected to HTTPS. I have to give back support for both version of web services.
I am using file_get_contents('php://input') to fetch variables from the requests from APPs, its working for all except JSON requests.
I googled alot and found the following solution but its not working as well.
$opts = array('http' =>
array(
'follow_location' => 1,
)
);
$context = stream_context_create($opts);
$result = file_get_contents('http://example.com/', false, $context);
also tried the same with
$result = file_get_contents('php://input', false, $context);
php://inputreads the already decrypted request body. Encryption does not happen at PHP level but one layer away, at web server level. I have the impression you're facing a specific issue but got a wrong diagnostic. But since you're asking about the diagnostic rather than the symptoms we can't really help you.