Commit 3321bb9b authored by hujun's avatar hujun

容联云号码回调

parent 2b174f58
......@@ -8,54 +8,54 @@
namespace app\api_broker\untils;
//use app\api_broker\untils\curlUntils;
use app\chat\utils\CurlUtil;
class RongDemo
{
/**
* 业务url/Accounts/{accountSid}/nme/{type}/{operatorId}/[/{op}]?sig={sigParameter}
* accountSid 账户id
* operatorId 合作运营商标识
* type 号码类型
* op 操作名
* sigParameter 访问签名
* appId 应用id
* authToken 访问授权码
* test_phone 测试中间号
*
*/
/**
* 业务url/Accounts/{accountSid}/nme/{type}/{operatorId}/[/{op}]?sig={sigParameter}
* accountSid 账户id
* operatorId 合作运营商标识
* type 号码类型
* op 操作名
* sigParameter 访问签名
* appId 应用id
* authToken 访问授权码
* test_phone 测试中间号
*
*/
public $base_url='https://apppro.cloopen.com:8883/2013-12-26';
public $components=[
'accountSid'=>'8a48b55153eae51101540e763d3b3888',
'appId'=>'8a216da85f5c89b1015f7718e2b90a63',
'appToken'=>'TOKEN3655166d16164b6ef25d6fa2a266acc1',
'authToken'=>'26b220de299d4a56a6f54dd5792a30e4'
];
public $test_phone='17080219070';
public $sign='';
public $statusCode=[
public $base_url = 'https://apppro.cloopen.com:8883/2013-12-26';
public $components = [
'accountSid' => '8a48b55153eae51101540e763d3b3888',
'appId' => '8a216da85f5c89b1015f7718e2b90a63',
'appToken' => 'TOKEN3655166d16164b6ef25d6fa2a266acc1',
'authToken' => '26b220de299d4a56a6f54dd5792a30e4'
];
public $test_phone = '17080219070';
public $sign = '';
public $statusCode = [
'000000' => '成功',
'300001' => '参数错误',
'300002' =>'验证错误',
'301101' =>'无号码资源',
'301201' =>'内部存储异常',
'301401' =>'无空闲号码',
'301402' =>'分配失败',
'301501' =>'类型号码未配置',
'301633' =>'找不到应用',
'320201' =>'号码已解绑',
'320400' =>'参数异常',
'320402' =>'号码已使用',
'320500' =>'落地异常',
'309000' =>'其它错误',
'300002' => '验证错误',
'301101' => '无号码资源',
'301201' => '内部存储异常',
'301401' => '无空闲号码',
'301402' => '分配失败',
'301501' => '类型号码未配置',
'301633' => '找不到应用',
'320201' => '号码已解绑',
'320400' => '参数异常',
'320402' => '号码已使用',
'320500' => '落地异常',
'309000' => '其它错误',
];
function __construct(){
function __construct()
{
//$this->sign = $this->sigParameter();
//$this->sign = $this->sigParameter();
}
......@@ -67,11 +67,11 @@ class RongDemo
*/
public function sigParameter($time)
{
$data=$this->components;
$data = $this->components;
//生成签名
$data['accountSid'].$data['authToken'].$time;
$data['accountSid'] . $data['authToken'] . $time;
$sign=strtoupper(md5($data['accountSid'].$data['authToken'].$time));
$sign = strtoupper(md5($data['accountSid'] . $data['authToken'] . $time));
return $sign;
}
......@@ -80,10 +80,11 @@ class RongDemo
* @param $time
* @return mixed
*/
public function Authorization($time){
$data=$this->components;
public function Authorization($time)
{
$data = $this->components;
$Authorization=base64_encode($data['accountSid'].':'.$time);
$Authorization = base64_encode($data['accountSid'] . ':' . $time);
return $Authorization;
}
......@@ -95,15 +96,16 @@ class RongDemo
* @param $operatorId 平台标识
* @return string
*/
public function url($type,$op='',$operatorId,$sign){
$data=$this->components;
$url_c="/Accounts/{$data['accountSid']}/nme/{$type}/{$operatorId}/{$op}?sig={$sign}";
$url=$this->base_url.$url_c;
public function url($type, $op = '', $operatorId, $sign)
{
$data = $this->components;
$url_c = "/Accounts/{$data['accountSid']}/nme/{$type}/{$operatorId}/{$op}?sig={$sign}";
$url = $this->base_url . $url_c;
return $url;
}
public function sendCurl($url,$arr,$Authorization)
public function sendCurl($url, $arr, $Authorization)
{
$data = json_encode($arr);
$curl = new CurlUtil();
......@@ -116,9 +118,8 @@ class RongDemo
"CURLOPT_SSL_VERIFYPEER" => 0,
"CURLOPT_SSL_VERIFYHOST" => 2,
];
//echo $url;
$response = $curl->post($url, $data);
$response = $curl->post($url, $data);
return $response;
}
......@@ -132,11 +133,12 @@ class RongDemo
* @param $yx_time
* @return string
*/
public function setNumber($aNumber,$bNumber,$xNumber,$areaCode,$yx_time='604800',$record){
$data = $this->components;
$time = date('YmdHis',time());
$sign = $this->sigParameter($time); /*签名*/
$url = $this->url('axb','setnumber','cu01',$sign);/*url*/
public function setNumber($aNumber, $bNumber, $xNumber, $areaCode, $yx_time = '604800', $record)
{
$data = $this->components;
$time = date('YmdHis', time());
$sign = $this->sigParameter($time); /*签名*/
$url = $this->url('axb', 'setnumber', 'cu01', $sign);/*url*/
$Authorization = $this->Authorization($time);/*认证信息*/
$post_data = [
......@@ -145,20 +147,15 @@ class RongDemo
'bNumber' => $bNumber,
'servingNumber' => $xNumber,
'areaCode' => $areaCode,
'needRecord' =>$record,
'mappingDuratio'=>$yx_time,
'cdrNotifyUrl' =>CURRENT_URL."task/rongBilledInformUrl",
'callStateNotifyUrl'=>CURRENT_URL."task/rongStatusInformUrl",
'recordNotifyUrl'=>CURRENT_URL."task/rongRecordingInformUrl",
// 'cdrNotifyUrl' =>"http://pre.tonglianjituan.com/task/rongBilledInfromUrl",
// 'callStateNotifyUrl'=>"http://pre.tonglianjituan.com/task/rongRecordingInfromUrl",
// 'recordNotifyUrl'=>"http://pre.tonglianjituan.com/task/rongStatusInfromUrl",
'needRecord' => $record,
'mappingDuratio' => $yx_time,
'cdrNotifyUrl' => CURRENT_URL . 'task/rongBilledInformUrl',
'callStateNotifyUrl' => CURRENT_URL . 'task/rongStatusInformUrl',
'recordNotifyUrl' => CURRENT_URL . 'task/rongRecordingInformUrl',
'userData' => $aNumber .'-'.$bNumber //记录a和b号码,回调使用
];
//var_dump($post_data);/*************测试****************/
$result = json_decode($this->sendCurl($url,$post_data,$Authorization),true);
return $result;
$result = json_decode($this->sendCurl($url, $post_data, $Authorization), true);
return $result;
}
/**
......@@ -166,35 +163,19 @@ class RongDemo
* @param $mappingId
* @return string
*/
public function releaseNumber($mappingId){
$data = $this->components;
$time = date('YmdHis',time());
$sign = $this->sigParameter($time); /*签名*/
$url = $this->url('axb','releasenumber','cu01',$sign);/*url*/
public function releaseNumber($mappingId)
{
$data = $this->components;
$time = date('YmdHis', time());
$sign = $this->sigParameter($time); /*签名*/
$url = $this->url('axb', 'releasenumber', 'cu01', $sign);/*url*/
$Authorization = $this->Authorization($time);/*认证信息*/
$post_data = [
'appId' => $data['appId'],
'mappingId'=>$mappingId
'mappingId' => $mappingId
];
$result = json_decode($this->sendCurl($url,$post_data,$Authorization),true);
$result = json_decode($this->sendCurl($url, $post_data, $Authorization), true);
return $result;
}
}
\ No newline at end of file
......@@ -164,14 +164,17 @@ class PrivacyNumber
'type' => 2,
'call_display' => $params['calldisplay'],
];
$phone_a = $params['callerNum'];
$phone = explode('-', $params['userData']);
$phone_a = $phone[0];
$phone_b = $phone[1];
if ($phone_a) {
$agents_id = Db::table('a_agents')->where('phone', $phone_a)->value('id');
if (empty($agents_id)) {
$agents_id = Db::table('a_agents_phone')->where('phone', $phone_a)->value('agents_id');
}
$date['agents_id'] = $agents_id;
$date['users_id'] = Db::table('u_users')->where('user_phone', $params['calleeNum'])->value('id');
$date['users_id'] = Db::table('u_users')->where('user_phone', $phone_b)->value('id');
}
$report = new SecretReport();
$report->allowField(true)->save($date);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment