SoulRend828
Fanatic
How to call CallRail API via PHP with Authentication token?
$api_url = "https://api.callrail.com/v3/a/{account_id}/calls.json";
$auth_token = "your_auth_token_here";
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_URL => $api_url,
CURLOPT_HTTPHEADER => array(
"Authorization: Token token=$auth_token",
"Content-Type: application/json"
)
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
{account_id} with your CallRail account ID, and your_auth_token_here with your CallRail API authentication token.calls.json endpoint of the CallRail API, with the Authorization header set to include your authentication token. The response from the API is stored in the $response variable, which is then printed to the page.$api_url to the relevant endpoint and updating any necessary request parameters in the CURLOPT_HTTPHEADER option.