Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
简化php curl代码_Php_Json_Curl - Fatal编程技术网

简化php curl代码

简化php curl代码,php,json,curl,Php,Json,Curl,我正在尝试从url获取JSON。我的代码正在运行,但我认为我可以做得更好。(删除json_解码或json_编码)。现在这就是我所拥有的:(编辑:我仍然想使用curl) 您可以尝试以下方法: $data = json_decode(file_get_contents('php://input')); print_r($data); 您可以尝试以下方法: $data = json_decode(file_get_contents('php://input')); print_r($data);

我正在尝试从url获取JSON。我的代码正在运行,但我认为我可以做得更好。(删除json_解码或json_编码)。现在这就是我所拥有的:(编辑:我仍然想使用curl)


您可以尝试以下方法:

$data = json_decode(file_get_contents('php://input'));
print_r($data);
您可以尝试以下方法:

$data = json_decode(file_get_contents('php://input'));
print_r($data);

您可以使用file_get_contents函数代替所有curl函数您可以使用file_get_contents函数代替所有curl函数