forked from FreePBX/superfecta
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'bugfix/FREEPBX-12072' of ssh://git.freepbx.org/freepbx/…
…superfecta into release/13.0
- Loading branch information
Showing
1 changed file
with
36 additions
and
32 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,50 @@ | ||
<?php | ||
/**** **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** | ||
* Developer Notes: | ||
* No longer using OAuth as of December '14 | ||
* No longer using OAuth as of December '14 | ||
* | ||
* Version History: | ||
* 2013-08-15 Initial commit by tm1000 | ||
* 2014-09-02 Support for OAuth 1.0a by ssanders76 | ||
* 2014-12-05 Support for API v2 w/ Basic Auth by RossIV | ||
* 2013-08-15 Initial commit by tm1000 | ||
* 2014-09-02 Support for OAuth 1.0a by ssanders76 | ||
* 2014-12-05 Support for API v2 w/ Basic Auth by RossIV | ||
* | ||
**** **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** ****/ | ||
|
||
class NextCaller extends superfecta_base { | ||
|
||
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' | ||
) | ||
); | ||
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); | ||
} | ||
} | ||
} | ||
} |