Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
361 views
in Technique[技术] by (71.8m points)

php - 无法使用文件获取内容php打开流(Failed to open stream using file get content php)

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...