Skip to content

Instantly share code, notes, and snippets.

@danielkellyio
Last active August 31, 2017 17:27
Show Gist options
  • Save danielkellyio/d50f3d17eb82ea46cf6e4ae74ea75c48 to your computer and use it in GitHub Desktop.
Save danielkellyio/d50f3d17eb82ea46cf6e4ae74ea75c48 to your computer and use it in GitHub Desktop.
Call Tracking Metrics API Call
/**
* Make a Call to the Call Metrics API
*
* @author Daniel Kelly
* @return void
*/
private function makeAPICall(){
header('Access-Control-Allow-Origin: *');
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "$this->api_endpoint . $this->form_reactor_id?phone_number=$this->phone&country_code=1&caller_name=$this->name",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => array(
"authorization: Basic " . base64_encode("$this->public_key:$this->private_key"),
"content-type: application/json"
)
));
$this->response = json_decode(curl_exec($curl));
$this->error = json_decode(curl_error($curl));
curl_close($curl);
if(strpos($this->response->status, 'error') === 0){
$this->error = $this->response->status;
}
if($this->error){
$this->reportFail();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment