Skip to content

Commit

Permalink
Merge branch 'bugfix/FREEPBX-12072' of ssh://git.freepbx.org/freepbx/…
Browse files Browse the repository at this point in the history
…superfecta into release/13.0
  • Loading branch information
tm1000 committed May 20, 2016
2 parents d3b13b8 + 1fc5372 commit 06cd41f
Showing 1 changed file with 36 additions and 32 deletions.
68 changes: 36 additions & 32 deletions sources/source-NextCaller.module
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);
}
}
}
}

0 comments on commit 06cd41f

Please sign in to comment.