diff --git a/sources/source-NextCaller.module b/sources/source-NextCaller.module index 4847c5c0..45673aa1 100644 --- a/sources/source-NextCaller.module +++ b/sources/source-NextCaller.module @@ -1,46 +1,50 @@ array( - 'description' => 'Username from NextCaller Dashboard', - 'type' => 'text' - ), - 'password' => array( - 'description' => 'Password from NextCaller Dashboard', - 'type' => 'password' - ) - ); + public $description = "http://nextcaller.com This source is free for up to 250 lookups/month, but you do need an account. Returns CID for any NANPA number without +1."; + public $version_requirement = "2.11"; + public $source_param = array( + 'username' => array( + 'description' => 'Username from NextCaller Dashboard', + 'type' => 'text' + ), + 'password' => array( + 'description' => 'Password from NextCaller Dashboard', + 'type' => 'password' + ) + ); - function get_caller_id($thenumber, $run_param=array()) { - $this->DebugPrint("Searching NextCaller.."); - if (!$run_param['username'] || !$run_param['password']) { - $this->DebugPrint("You did not specify a valid username or password."); + public function get_caller_id($thenumber, $run_param=array()) { + $this->DebugPrint("Searching NextCaller.."); + $run_param['username'] = isset($run_param['username'])?$run_param['username']:false; + $run_param['password'] = isset($run_param['password'])?$run_param['password']:false; + $thenumber=urlencode($thenumber); + $caller_id = null; + if (!$run_param['username'] || !$run_param['password']) { + $this->DebugPrint("You did not specify a valid username or password."); + } else { + $url = "https://".$run_param['username'].":".$run_param['password']."@api.nextcaller.com/v2/records/?format=json&phone=$thenumber"; + $sresult = $this->get_url_contents($url); + $result = json_decode($sresult, true); + $name = isset($result['records']['0']['name'])?$result['records']['0']['name']:''; + // If we found a match, return it + if (strlen($name) > 1) { + $caller_id = $name; } else { - $url = "https://".$run_param['username'].":".$run_param['password']."@api.nextcaller.com/v2/records/?format=json&phone=$thenumber"; - $sresult = $this->get_url_contents($url); - $result = json_decode($sresult, true); - $name = $result['records']['0']['name']; - // If we found a match, return it - if (strlen($name) > 1) { - $caller_id = $name; - } else { - $this->DebugPrint("not found"); - } - return($caller_id); + $this->DebugPrint("not found"); } + return($caller_id); } -} \ No newline at end of file + } +}