|
|
@@ -16,17 +16,47 @@ namespace app\common\service\call;
|
|
|
|
|
|
class VirtualCallService
|
|
|
{
|
|
|
+ public static $host = 'https://101.37.133.245:11008/';
|
|
|
+ public static $appId = '989460';
|
|
|
+ public static $accessToken = 'edcd07d7216446b6ae549a2e621eb42b';
|
|
|
+
|
|
|
+ public static function timestamp(){
|
|
|
+ $time = explode (" ", microtime () );
|
|
|
+ return $time[1] . "000";
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * @notes 鉴权
|
|
|
+ */
|
|
|
+ public static function auth($bindNumberA, $bindNumberB, $maxBindingTime = 60)
|
|
|
+ {
|
|
|
+ $timestamp = self::timestamp();
|
|
|
+ $sig = md5(self::$appId.self::$accessToken.$timestamp);
|
|
|
+ $authorization = base64_encode(self::$appId.":".$timestamp);
|
|
|
+ $url = self::$host . 'voice/1.0.0/middleNumberAXB/'.self::$appId.'/'.$sig;
|
|
|
+ $header = [
|
|
|
+ "Accept:application/json",
|
|
|
+ "Content-Type:application/json;charset=utf-8",
|
|
|
+ "Authorization:$authorization"
|
|
|
+ ];
|
|
|
+ $params = [
|
|
|
+ //"middleNumber" => "13003426180",
|
|
|
+ "bindNumberA" => $bindNumberA,
|
|
|
+ "bindNumberB" => $bindNumberB,
|
|
|
+ "maxBindingTime" => $maxBindingTime
|
|
|
+ ];
|
|
|
+ $params = json_encode($params);
|
|
|
+ $response = http_request($url, $params, $header);
|
|
|
+ return $response;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
- * @notes 设置配置值
|
|
|
- * @param $type
|
|
|
- * @param $name
|
|
|
- * @param $value
|
|
|
- * @return mixed
|
|
|
- * @author 段誉
|
|
|
- * @date 2021/12/27 15:00
|
|
|
+ * @notes 虚拟外呼回调通知
|
|
|
*/
|
|
|
- public static function set(string $type, string $name, $value)
|
|
|
+ public static function notify($params)
|
|
|
{
|
|
|
- return '';
|
|
|
+ if (empty($params['appId']) || $params['appId'] != self::$appId) {
|
|
|
+ return ['resultCode' => "200"];
|
|
|
+ }
|
|
|
+ return ['resultCode' => "200"];
|
|
|
}
|
|
|
}
|