Your code has some problems.
Let's list them:
1. Misuse of print_r
print_r
is not used to store values in variables, but to print values already stored.
Therefore this code is incorrect:
$rawPostData .= print_r($GLOBALS['HTTP_RAW_POST_DATA'], TRUE);
2. HTTP_RAW_POST_DATA
is obsolete
According to the PHP Manual :
HTTP_RAW_POST_DATA
This feature was declared OBSOLETE in
PHP 5.6.0 and ELILMINED as of PHP 7.0.0.
Therefore, if you are using PHP 7, you will not get anything with this:
$rawPostData .= print_r($GLOBALS['HTTP_RAW_POST_DATA'], TRUE);
HTTP_RAW_POST_DATA
has been replaced by php://input
as the PHP Manual says :
php://input
is a read-only flow that allows you to read data from the
requested body. In the case of POST requests, it is preferable to use
php://input
instead of $HTTP_RAW_POST_DATA
since it does not depend on
special php.ini directives. However, when it is not generated
automatically $HTTP_RAW_POST_DATA
, it is an alternative that
makes less intensive use of memory than activating
always_populate_raw_post_data
php://input
is not available with
enctype="multipart/form-data
.
3. The case of HTTP_DEVICEID
does not appear documentation about it
Obviously you try to get the device id. I did not find data about that. In SO in English they suggest reading the User-Agent data to obtain it or using third-party libraries.
We will apply the corrections mentioned:
//$deviceID = $_SERVER['HTTP_DEVICEID'];
//$rawPostData = "DeviceID: ".$deviceID."\n"; ver como obtenerlo
$rawPostData = file_get_contents("php://input");
/*Aquí puedes revisar lo que hay en $rawPostData con print_r*/
print_r($rawPostData);
$filedatetime=date('ymdHis');
$rawPostFile = "data/playlog_".$filedatetime.".txt";
$rawPostHandler = fopen($rawPostFile, 'w') or die('Could not open file!');
fwrite($rawPostHandler, $rawPostData) or die('Could not write to file');
fclose($rawPostHandler);
$fileStream .= $rawPostData;