Now this line prints cont empty: $cont = file_get_contents(’ PHP ://input’);
I wonder if my client configured the connection to the server incorrectly
In addition, is the log added at this interface or at the Linux server
Now this line prints cont empty: $cont = file_get_contents(’ PHP ://input’);
I wonder if my client configured the connection to the server incorrectly
we have a sample data file sample_gateway4_data.txt
in the php examples directory. please try to post the content to your WEB API.
e.g.
curl --data-binary "@./sample_gateway4_data.txt" http://care.xd102.com/api/lanya/get_lanya
Please fix the path for sample_gateway4_data.txt first
How do I use this file?Is it necessary?To introduce in the interface or what?
the content of sample_gateway4_data.txt
is what gateway will post to your interface. You can use it to simulate the request of gateway and debug your interface.
Now I should be the gateway data has not been uploaded to the server, the server has not received, is it my configuration error?
Could you please give me your contact information? My account of this forum is out of balance right now!
First, the sample_data.txt
is just for BLE Gateway V2. Please replace it with sample_gateway4_data.txt
instead.
Second, the txt file is just a sample data. You can only use it to test your parsing code. It can’t work for final stage.
BTW. I changed your user level to “regular”. It should make your account to better.
change the line to
$data = @msgpack_unpack($cont);
let me know if this work
Here’s a simple parse script
<?php
$sampleFile = 'sample_gateway4_data.txt';
$cont = file_get_contents($sampleFile);
$data = @msgpack_unpack($cont);
var_dump($data);
the output
array(6) {
["v"]=>
string(8) "1.1.0.23"
["mid"]=>
int(19)
["time"]=>
int(43)
["ip"]=>
string(12) "192.168.0.25"
["mac"]=>
string(12) "807D3ACA33B0"
["devices"]=>
array(44) {
[0]=>
string(39) "2G??D?? ?4?S??=8v]?a?
" ??L??
...
Do you use any framework to build your application? Does it possible disable read php://input
?
If that doesn’t work, check the console for errors and your php settings:
tail -f /path/to/the/php/log/file
so you can actually see the output of these php calls.file_get_contents(file://input): failed to open stream: no suitable wrapper could be found
which can indicate either a typo of the “file://input” string or the fact that allow_url_fopen
is disabled in php (see #5 if unsure)file_get_contents
only works when allow_url_fopen
is set to true in your PHP settings. thats something that is set in php.ini, but you can also change settings at run time by writing something along the lines of the following code before the other code:ini_set("allow_url_fopen", true);
File_get_contents is fine, is it because my gateway client is not configured correctly
you should check where the log file of your php settings is placed. run the code to get the information
phpinfo();