PHP隐私保护通话,AXB模式绑定接口_隐私保护通话 PrivateNumber_API参考_AXB模式_华为云...

200

0

Success.

成功。

-

400

1023006

Authorization not contained in the HTTP header.

HTTP消息头未找到Authorization字段。

请检查HTTP消息头中是否携带了Authorization字段。

1023007

realm not contained in Authorization.

Authorization字段中未找到realm属性。

请检查Authorization字段中的是否携带了realm属性。

1023008

profile not contained in Authorization.

Authorization字段中未找到profile属性。

请检查Authorization字段中的是否携带了profile属性。

1023009

The value of realm in Authorization must be SDP.

Authorization中realm属性值应该为“SDP”。

请检查Authorization字段中的realm属性值是否为“SDP”。

1023010

The value of profile in Authorization must be UsernameToken.

Authorization中profile属性值应该为“UsernameToken”。

请检查Authorization字段中的profile属性值是否为“UsernameToken”。

1023011

The value of type in Authorization must be app_key.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
这段代码是干什么用的# -*- coding: utf-8 -*- import time import uuid import hashlib import base64 import ssl import urllib.request import hmac from hashlib import sha256 # 必填,请参考"开发准备"获取如下数据,替换为实际值 realUrl = 'https://rtcpns.cn-north-1.myhuaweicloud.com/rest/caas/relationnumber/partners/v1.0' #APP接入地址+接口访问URI APP_KEY = "a1********" #APP_Key APP_SECRET = "cfc8********" #APP_Secret ''' 选填,各参数要求请参考"AXB模式解绑接口" subscriptionId和relationNum为二选一关系,两者都携带时以subscriptionId为准 ''' subscriptionId = '****' #指定"AXB模式绑定接口"返回的绑定ID进行解绑 relationNum = '+86170****0001' #指定X号码(隐私号码)进行解绑 def buildAKSKHeader(appKey, appSecret): now = time.strftime('%Y-%m-%dT%H:%M:%SZ') #Created nonce = str(uuid.uuid4()).replace('-','') #Nonce digist = hmac.new(appSecret.encode(), (nonce + now).encode(), digestmod=sha256).digest() digestBase64 = base64.b64encode(digist).decode() #PasswordDigest return 'UsernameToken Username="{}",PasswordDigest="{}",Nonce="{}",Created="{}"'.format(appKey, digestBase64, nonce, now); def main(): # 请求URL参数 formData = urllib.parse.urlencode({ 'subscriptionId':subscriptionId, 'relationNum':relationNum }) #完整请求地址 fullUrl = realUrl + '?' + formData req = urllib.request.Request(url=fullUrl, method='DELETE') #请求方法为DELETE # 请求Headers参数 req.add_header('Authorization', 'AKSK realm="SDP",profile="UsernameToken",type="Appkey"') req.add_header('X-AKSK', buildAKSKHeader(APP_KEY, APP_SECRET)) req.add_header('Content-Type', 'application/json;charset=UTF-8') # 为防止因HTTPS证书认证失败造成API调用失败,需要先忽略证书信任问题 ssl._create_default_https_context = ssl._create_unverified_context try: print(formData) #打印请求数据 r = urllib.request.urlopen(req) #发送请求 print(r.read().decode('utf-8')) #打印响应结果 except urllib.error.HTTPError as e: print(e.code) print(e.read().decode('utf-8')) #打印错误信息 except urllib.error.URLError as e: print(e.reason) if __name__ == '__main__': main()
06-10

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值