Advice and answers from the Callyzer Team

How to call API using PHP?

Twinkle Pithwa
By Twinkle Pithwa Updated over 2 years ago

Here is the code to the call Callyzer API using the PHP CURL function.

<?php

// API Url to fetch call history
$url = "https://api1.callyzer.co/admin/api/call/callHistory";

// Access Token
$accessToken = 'API_TOKEN';

$data = [
    'callStartDate' =--> '2023-01-20',
    'callEndDate' => '2023-01-24',
    'employeeNumbers'=> '9998875555',
    'callTypes'=> 'Incoming,Outgoing',
    'excludeNumbers' => 'False',
    'recordFrom' => '100',
    'pageSize' => '50',
];

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_POSTFIELDS,json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    "Authorization: Bearer " . $accessToken,
    "Content-Type: application/json"
));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($ch);

if ($response === false) {

    echo "cURL Error: " . curl_error($ch);
} else {
    
    echo "Response: " . $response;
}

curl_close($ch);
?>

Did this answer your question?

  1. Happy
  2. Sad
  3. Angry