I've pasted my code below. I'm getting an empty string back, no curl error or anything.
$service_url = "https://api.insight.ly/v2.1/Opportunities";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $service_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLINFO_HEADER_OUT, true);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_USERPWD, "-my-base64-encoded-api-key");
$data = curl_exec($ch);
curl_close($ch);
since the documentation for the Insightly API said to leave password blank, i've also tried
curl_setopt($ch, CURLOPT_USERPWD, "-my-base64-encoded-api-key:");
and
curl_setopt($ch, CURLOPT_USERPWD, "-my-base64-encoded-api-key: ");
Any help would be appreciated. Thank you.
Below is the working code - I had to send the authorization in the header, not as an option in CURL. I didn't know this was possible. Insightly support came through and provided me with additional instructions. I am posting the answer below in case someone else runs into this problem.
$service_url = 'https://api.insight.ly/v2.1/Opportunities';
$ch = curl_init($service_url);
curl_setopt($ch,
CURLOPT_HTTPHEADER,
array('Content-Type: application/json',
'Authorization: Basic my-base64-encoded-api-key'));
curl_setopt($ch , CURLOPT_HEADER, 0);
curl_setopt($ch , CURLOPT_TIMEOUT, 30);
curl_setopt($ch , CURLOPT_HTTPGET, 1);
curl_setopt($ch , CURLOPT_RETURNTRANSFER, TRUE);
$return = curl_exec($ch );
curl_close($process);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With