|
|
<?php
|
|
|
|
|
|
namespace ali\alibabacloud\phonenumberprotection;
|
|
|
|
|
|
use AlibabaCloud\SDK\Dyplsapi\V20170525\Models\BindAxbRequest;
|
|
|
use AlibabaCloud\SDK\Dyplsapi\V20170525\Models\BindAxnRequest;
|
|
|
use AlibabaCloud\SDK\Dyplsapi\V20170525\Models\UnbindSubscriptionRequest;
|
|
|
|
|
|
|
|
|
class Phone extends Base
|
|
|
{
|
|
|
|
|
|
/**
|
|
|
* 号码绑定Axb
|
|
|
* @param string $pool_key 号码池Key。在号码池管理中查看号码池Key。
|
|
|
* @param string $phone_number_A AXB中的A号码。A号码可设置为手机号码或固定电话,固定电话需要加区号,区号和号码中间不需要加连字符,例如0571xxxx688。
|
|
|
* @param string $phone_number_B AXB中的B号码,A号码拨打X号码时会转接到B号码。B号码可设置为手机号码或固定电话,固定电话需要加区号,区号和号码中间不需要加连字符,例如0571xxxx688。
|
|
|
* @param string $expiration 绑定关系的过期时间。
|
|
|
* @param string $is_recording_enabled 是否需要针对该绑定关系产生的所有通话录制通话录音。 true--录音 false--不录音
|
|
|
* @param string $phone_number_X 非必填 AXB中的X号码。如果未指定X号码,将根据参数ExpectCity从指定号码池中随机指定一个号码作为X号码。
|
|
|
* @date 2021-03-26
|
|
|
*/
|
|
|
public function bindAxb($pool_key, $phone_number_A, $phone_number_B, $expiration, $is_recording_enabled = 'false', $phone_number_X = '')
|
|
|
{
|
|
|
$client = self::createClient();
|
|
|
|
|
|
$data = [
|
|
|
"poolKey" => $pool_key,
|
|
|
"phoneNoA" => $phone_number_A,
|
|
|
"phoneNoB" => $phone_number_B,
|
|
|
"phoneNoX" => $phone_number_X,
|
|
|
"expiration" => $expiration,
|
|
|
"isRecordingEnabled" => $is_recording_enabled
|
|
|
];
|
|
|
$bindAxbRequest = new BindAxbRequest($data);
|
|
|
// 复制代码运行请自行打印 API 的返回值
|
|
|
$result = $client->bindAxb($bindAxbRequest);
|
|
|
|
|
|
$result_array = $result->toMap();
|
|
|
$result = $result_array['body'];
|
|
|
|
|
|
// 记录日志
|
|
|
$uid = defined('UID') ? UID : '';
|
|
|
platformLog($data, $result, 'alibaba_cloud_phone_number_protection_bind_axb_uid_' . $uid);
|
|
|
|
|
|
return $result;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 号码绑定Axn
|
|
|
* @param string $pool_key 号码池Key。在号码池管理中查看号码池Key。
|
|
|
* @param string $phone_number_A AXN中的A号码。A号码可设置为手机号码或固定电话,固定电话需要加区号,区号和号码中间不需要加连字符,例如0571xxxx688。
|
|
|
* @param string $phone_number_B 非必填 AXN中的B号码,A号码拨打X号码时会转接到B号码。B号码可设置为手机号码或固定电话,固定电话需要加区号,区号和号码中间不需要加连字符,例如0571xxxx2688。
|
|
|
* @param string $expiration 绑定关系的过期时间。
|
|
|
* @param string $is_recording_enabled 是否需要针对该绑定关系产生的所有通话录制通话录音。 true--录音 false--不录音
|
|
|
* @param string $phone_number_X 非必填 AXN中的X号码。如果未指定X号码,将根据参数ExpectCity从指定号码池中随机指定一个号码作为X号码。
|
|
|
* @date 2021-03-26
|
|
|
*/
|
|
|
public function bindAxn($pool_key, $phone_number_A, $expiration, $phone_number_B = '', $is_recording_enabled = 'false', $phone_number_X = '')
|
|
|
{
|
|
|
$client = self::createClient();
|
|
|
|
|
|
$data = [
|
|
|
"poolKey" => $pool_key,
|
|
|
"phoneNoA" => $phone_number_A,
|
|
|
"phoneNoB" => $phone_number_B,
|
|
|
"phoneNoX" => $phone_number_X,
|
|
|
"expiration" => $expiration,
|
|
|
"isRecordingEnabled" => $is_recording_enabled
|
|
|
];
|
|
|
$bindAxnRequest = new BindAxnRequest($data);
|
|
|
|
|
|
// 复制代码运行请自行打印 API 的返回值
|
|
|
$result = $client->bindAxn($bindAxnRequest);
|
|
|
|
|
|
$result_array = $result->toMap();
|
|
|
$result = $result_array['body'];
|
|
|
|
|
|
// 记录日志
|
|
|
$uid = defined('UID') ? UID : '';
|
|
|
platformLog($data, $result, 'alibaba_cloud_phone_number_protection_bind_axn_uid_' . $uid);
|
|
|
|
|
|
return $result;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 解除号码绑定
|
|
|
* @param string $subs_id 绑定关系ID
|
|
|
* @param string $secret_no 隐私号码
|
|
|
* @date 2021-03-26
|
|
|
*/
|
|
|
public function unbind($subs_id, $secret_no)
|
|
|
{
|
|
|
$client = self::createClient();
|
|
|
|
|
|
$data = [
|
|
|
"subsId" => $subs_id,
|
|
|
"secretNo" => $secret_no
|
|
|
];
|
|
|
$unbindSubscriptionRequest = new UnbindSubscriptionRequest($data);
|
|
|
// 复制代码运行请自行打印 API 的返回值
|
|
|
$result = $client->unbindSubscription($unbindSubscriptionRequest);
|
|
|
|
|
|
$result_array = $result->toMap();
|
|
|
$result = $result_array['body'];
|
|
|
|
|
|
// 记录日志
|
|
|
$uid = defined('UID') ? UID : '';
|
|
|
platformLog($data, $result, 'alibaba_cloud_phone_number_protection_unbind_uid_' . $uid);
|
|
|
|
|
|
return $result;
|
|
|
}
|
|
|
|
|
|
}
|