|
|
@@ -13,6 +13,7 @@
|
|
|
// +----------------------------------------------------------------------
|
|
|
|
|
|
namespace app\common\service\call;
|
|
|
+use think\facade\Cache;
|
|
|
|
|
|
class VirtualCallService
|
|
|
{
|
|
|
@@ -42,7 +43,8 @@ class VirtualCallService
|
|
|
//"middleNumber" => "13003426180",
|
|
|
"bindNumberA" => $bindNumberA,
|
|
|
"bindNumberB" => $bindNumberB,
|
|
|
- "maxBindingTime" => $maxBindingTime
|
|
|
+ "maxBindingTime" => $maxBindingTime,
|
|
|
+ "callbackUrl" => "",
|
|
|
];
|
|
|
$params = json_encode($params);
|
|
|
$response = http_request($url, $params, $header);
|
|
|
@@ -59,4 +61,89 @@ class VirtualCallService
|
|
|
}
|
|
|
return ['resultCode' => "200"];
|
|
|
}
|
|
|
+
|
|
|
+ //////////////////优音云平台//////////////////////////
|
|
|
+ //外显固话
|
|
|
+ public static function addHiddedPhone($bindNumberA, $bindNumberB){
|
|
|
+ $url = 'https://xtapi.uincall.com/api/call/addHiddedPhone.action';
|
|
|
+ $header = [
|
|
|
+ "Content-Type:application/x-www-form-urlencoded;charset=UTF-8"
|
|
|
+ ];
|
|
|
+ $data = json_encode([['phone1' => $bindNumberA, 'phone2' => $bindNumberB]]);
|
|
|
+ //echo $data;die;
|
|
|
+ $params = [
|
|
|
+ 'appver' => '1',
|
|
|
+ 'timestamp' => date('YmdHis'),
|
|
|
+ 'user' => '075533318487_dev',
|
|
|
+ 'account' => '075533318487',
|
|
|
+ 'data' => ($data),
|
|
|
+ ];
|
|
|
+ $token = self::getToken();
|
|
|
+ $params['secret'] = self::getSecret($params, $token);
|
|
|
+ $params = http_build_query($params, '=', '&');
|
|
|
+ $response = http_request($url, $params, $header);
|
|
|
+ return $response;
|
|
|
+ }
|
|
|
+
|
|
|
+ //外显小号
|
|
|
+ public static function bind($bindNumberA, $bindNumberB, $maxBindingTime = 60){
|
|
|
+ $url = 'https://xtapi.uincall.com/api/call/bindHiddedPhone.action';
|
|
|
+ $header = [
|
|
|
+ "Content-Type:application/x-www-form-urlencoded;charset=UTF-8"
|
|
|
+ ];
|
|
|
+ $params = [
|
|
|
+ 'appver' => '1',
|
|
|
+ 'timestamp' => date('YmdHis'),
|
|
|
+ 'user' => '075533318487_dev',
|
|
|
+ 'account' => '075533318487',
|
|
|
+ 'callingId' => $bindNumberA,
|
|
|
+ 'transferNum' => $bindNumberB,
|
|
|
+ 'expiration' => $maxBindingTime,
|
|
|
+ ];
|
|
|
+ $token = self::getToken();
|
|
|
+ $params['secret'] = self::getSecret($params, $token);
|
|
|
+ $params = http_build_query($params, '=', '&');
|
|
|
+ $response = http_request($url, $params, $header);
|
|
|
+ return $response;
|
|
|
+ }
|
|
|
+
|
|
|
+ public static function getToken()
|
|
|
+ {
|
|
|
+ if ($token = Cache::get('uincall_token')) {
|
|
|
+ return $token;
|
|
|
+ }
|
|
|
+ $url = 'https://xtapi.uincall.com/api/call/union400Login.action';
|
|
|
+ $header = [
|
|
|
+ "Content-Type:application/x-www-form-urlencoded;charset=UTF-8"
|
|
|
+ ];
|
|
|
+ $params = [
|
|
|
+ 'appver' => '1',
|
|
|
+ 'timestamp' => date('YmdHis'),
|
|
|
+ 'user' => '075533318487_dev',
|
|
|
+ ];
|
|
|
+ $params['secret'] = self::getSecret($params, 'da7fd311e57a46af88eb972d47ebc954');
|
|
|
+ $params = http_build_query($params, '=', '&');
|
|
|
+ $response = http_request($url, $params, $header);
|
|
|
+ if (isset($response['errcode']) && $response['errcode'] == 0) {
|
|
|
+ $exp = strtotime($response['data']['expiredtime']) - time();
|
|
|
+ Cache::set('uincall_token', $response['data']['token'], $exp);
|
|
|
+ return $response['data']['token'];
|
|
|
+ }
|
|
|
+ return "";
|
|
|
+ }
|
|
|
+
|
|
|
+ public static function getSecret($params,$token)
|
|
|
+ {
|
|
|
+ //按键值名排序
|
|
|
+ ksort($params);
|
|
|
+ $str = '';
|
|
|
+ foreach ($params as $key => $value) {
|
|
|
+ if ($value !== '' && $value !== null) {
|
|
|
+ $str .= $key . $value;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $str .= $token;
|
|
|
+ $sign = md5($str);
|
|
|
+ return $sign;
|
|
|
+ }
|
|
|
}
|