-
-
Save stianeklund/e9d7541161d7c205d6b8 to your computer and use it in GitHub Desktop.
Death
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** | |
* CapsuleCRM Rest API Caller ID Lookup | |
* | |
* Written by Stian Eklund | |
* | |
* | |
*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***/ | |
class CapsuleCRM extends superfecta_base { | |
public $description = "CapsuleCRM lookups"; | |
public $version_requirement = "2.11"; | |
function get_caller_id($thenumber, $run_param=array()) { | |
$caller_id = null; | |
$name = ""; | |
$spam = ""; | |
$this->DebugPrint("Searching Capsule - {$this->thenumber} ... "); | |
// Search Capsule | |
$url = "https://stianeklund.capsulecrm.com/api/party?q=$thenumber"; | |
$this->DebugPrint($url); // for debug | |
$crl = curl_init(); | |
$timeout = 5; | |
curl_setopt ($crl, CURLOPT_URL,$url); | |
curl_setopt ($crl, CURLOPT_RETURNTRANSFER, 1); | |
curl_setopt ($crl, CURLOPT_CONNECTTIMEOUT, $timeout); | |
curl_setopt ($crl, CURLOPT_USERPWD, '[937680bd55b27297ad85b2441a9ada60]:[x]'); | |
curl_setopt ($crl, CURLOPT_HTTPHEADER, array('Content-Type: application/json')); | |
curl_setopt ($crl, CURLOPT_HEADER, true); | |
$result = (array)json_decode($url, true); | |
// echo $result; | |
$ret = curl_exec($crl); | |
curl_close($crl); | |
// return $ret; | |
// $value = $this->get_url_contents($url); | |
// $result = (array)json_decode($value,true); | |
if (isset($result['phone']['company'])) { | |
if ($result['phone']['company'] == 'Not Found') { | |
//record not found | |
} else { | |
$name = trim($result['phone']['company']); | |
} | |
} | |
// If we found a match, return it | |
if (strlen($name) > 1) { | |
$caller_id = $name; | |
} else { | |
$this->DebugPrint("not found"); | |
} | |
return($caller_id); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment