隐私保护通话 PrivateNumber-AX模式:短信通知接口

时间:2025-02-12 14:52:30

短信通知接口

 1 2 3 4 5 6 7 8 9101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
/** * 短信通知 * 客户平台收到 隐私保护通话 平台的短信通知的接口通知 *///短信通知样例var jsonBody = JSON.stringify({    'appKey': '****',    'smsEvent': {        'smsIdentifier': '****',        'notificationMode': 'Block',        'calling': '+86138****0001',        'virtualNumber': '+86138****0000',        'event': 'Text SMS ',        'timeStamp': '2018-09-13T09:46:16.023Z'    }});console.log('jsonBody:', jsonBody);/** * 短信通知 * @brief 详细内容以接口文档为准 * @param jsonBody * @returns */function onSmsEvent(jsonBody) {    var jsonObj = JSON.parse(jsonBody); //将通知消息解析为jsonObj    if (!jsonObj.hasOwnProperty('smsEvent')) {        console.log('param error: no smsEvent.');        return;    }    //console.log('appKey:', jsonObj.appKey); //商户应用的AppKey    var smsEvent = jsonObj.smsEvent; //短信通知信息    /**     * Example: 此处以解析notificationMode为例,请按需解析所需参数并自行实现相关处理     *      * 'smsIdentifier': 短信唯一标识     * 'notificationMode': 通知模式     * 'calling': 真实发送方号码     * 'called': 真实接收方号码     * 'virtualNumber': 隐私号码(X号码)     * 'event': 短信状态事件     * 'timeStamp': 短信事件发生的系统时间戳,UTC时间     * 'subscriptionId': 绑定ID     * 'smsContent': 用户发送的短信内容     */    if (smsEvent.hasOwnProperty('notificationMode')) {        if ('Block' === smsEvent.notificationMode) {            //收到隐私保护通话平台的短信通知,若为Block模式,请参考接口文档回消息指示下一步操作            var actions = {                'operation': 'vNumberRoute', //操作类型:转发短信/丢弃短信                'message': {                    'called': '+86138****7022', //真实接收方号码                    'calling': '+86138****7021' //真实发送方号码                }            };            var resp = JSON.stringify({'actions': [actions]}); //Block模式响应消息            console.log('resp:', resp);        } else if ('Notify' === smsEvent.notificationMode) {            //收到隐私保护通话平台的短信通知,若为Notify模式,请回HTTP状态码为200的空消息            //var statusCode = 200;            console.log('This is AX sms Notify mode.');        } else {            console.log('notificationMode param error.');        }    }}//短信通知处理onSmsEvent(jsonBody);
support.huaweicloud.com/devg-PrivateNumber/privatenumber_01_0015.html