I have problems retrieving the data that an external server sends to me. I'll explain better: to change the status of a record in my database, I contact an external application, which sends to the application I've created the result of the call in the header.
Now, my question is: if I have file_get_contents("php://input")
blocked or restricted in my server, do I have an alternative solution to retrieve that data? If yes, what does it is?
EDIT: here's an example of code.
//the function will be called every time the external server calls my file
function remoteValidation(){
$requestData = file_get_contents("php://input");
if (isset($requestData) && !empty($requestData) && $requestData['signature'] == $this->savedSignature) {
// validation on the signature
} else {
throw new Exception ('The signature is not valid, or is empty!);
}
}
file_get_contents("php://input")
will give you the raw data, so you won't be able to access it as an array (like in $requestData['signature']
). You would first have to parse in according to its "real" format (like json_decode
if it is JSON).
Alternatives - if you're definitely not able to use file_get_contents("php://input")
on your server - would be using a GET
request als @CD001 stated or possibly using the request headers to transfer your information.
If you have no influence on how the external server sends the data to you, it could be possible to use $HTTP_RAW_POST_DATA
- but please note that you shouldn't to so if you can avoid it as is deprecated and was removed in PHP7 anyway.