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';
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.