I have a token (string held in $token) and I need to retrieve a response (JSON) from an online service using curl.
The API requires GET.
$crl = curl_init();
$headr = array();
$headr[] = 'Content-length: 0';
$headr[] = 'Content-type: application/json';
$headr[] = 'Authorization: OAuth '.$token;
curl_setopt($crl, CURLOPT_HTTPHEADER,$headr);
$url = "ENDPOINT";
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_HTTPGET, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$rest = curl_exec($crl);
curl_close($crl);
var_dump($rest);
Dumping $rest gives me:
bool(false)
I based the above on this thread