I want to send data in json meta to API but I got error "failed to open stream: HTTP request failed! HTTP/1.1 400 Bad Request".
(我想将json meta中的数据发送到API,但出现错误“无法打开流:HTTP请求失败!HTTP / 1.1 400错误请求”。)
Here is my example of code to send json meta to my API through file_get_contents
;
(这是我通过file_get_contents
将json meta发送到我的API的代码示例;)
$reports_arr["param1"]=urlencode("data1");
$reports_arr["param2"]=urlencode("data2");
$json = json_encode($reports_arr);
$json = file_get_contents("http://www.example.com/filename.php?jsonMeta=$json");
$json= json_decode($json,true);
$status = $json['status'];
echo $status;
For your guys information, I'm using PHP 7 and Xampp for this project.
(供大家参考,我正在为该项目使用PHP 7和Xampp。)
Why I receive the error message?
(为什么我会收到错误消息?)
It's the code; (这是代码;)
or xammp; (或xammp;)
or server configuration problem? (还是服务器配置问题?)
ask by Jalon Juanis translate from so 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…