当前位置: 动力学知识库 > 问答 > 编程问答 >

php - Curl Script Returning False

问题描述:

I am getting bool(false) when I var_dump $information I can access the API fine via the browser just not via the code below why?

 $json = file_get_contents('API URL');

$ch = curl_init();

curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

curl_setopt($ch, CURLOPT_URL, $json);

curl_setopt($ch, CURLOPT_USERPWD, "user:pw");

curl_error($ch);

$result = curl_exec($ch);

curl_close($ch);

$information = json_decode($result, true);

var_dump($result);

网友答案:

This line

$json = file_get_contents('API URL');

should be

 $json = 'API_URL';
分享给朋友:
您可能感兴趣的文章:
随机阅读: