cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
3955members
1278posts

Connecting to API with PHP cURL

monroeruss
Contributor Level 1

Has anyone had any success with connecting to the Invoca API using PHP and cURL? Documentation says that the API requires OAuth authentication, but when attempting to connect, the result returns "HTTP Basic: Access Denied." Which tells me that the API is using HTTP Basic Authentication. This is what I have so far..

$crid = 'call-record-id';
$token = 'unique-token';
$url = 'https://myinvocaprofile.invoca.net/call/transcript/'.$crid.'?transcript_format=caller_agent_conversa...';
$headers = array (
'Accept: application/json',
'Content-Type: application/json',
'Content-length: 0',
'Authorization: Bearer ',$token
);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_ENCODING, '');
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers );
curl_setopt($ch, CURLOPT_HTTPGET, true);
$result = curl_exec($ch);
$result_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$transcript = json_decode($result, true);
echo '<pre>';
print_r($result);
echo '</pre>';
echo '<hr>';
print_r($transcript);

1 REPLY 1

jroe
Employee
Employee

There is an example at the bottom of this page that shows the oauth token in the header of a curl request: https://developers.invoca.net/en/2022-08-01/api_documentation/transactions_api/affiliate_user.html

Looks like it does not use the "Bearer" part.