开发者社区> 问答> 正文

NETAXN绑定接口



AXN绑定接口(Axnbind)



步骤 1 创建阿里云账号


为了访问AXN隐私号服务,您需要有一个阿里云账号。如果没有,可首先按照如下步骤创建阿里云账号:

  1. 访问阿里云 官方网站,单击页面上的 免费注册 按钮。
  2. 按照屏幕提示完成注册流程并进行实名认证,AXN隐私号服务只支持实名认证用户使用。为了更好地使用阿里云服务,建议尽快完成实名认证,否则部分阿里云服务将无法使用。具体实名认证流程,请参考 这里


步骤 2 获取阿里云访问密钥


为了使用AXN隐私号绑定API-.NET SDK,您必须申请阿里云的访问密钥。
阿里云访问秘钥是阿里云为用户使用 API(非控制台)来访问其云资源设计的“安全口令”。您可以用它来签名 API 请求内容以通过服务端的安全验证。
该访问秘钥成对(AccessKeyId 与 AccessKeySecret)生成和使用。每个阿里云用户可以创建多对访问秘钥,且可随时启用(Active)、禁用(Inactive)或者删除已经生成的访问秘钥对。
您可以通过阿里云控制台的 秘钥管理页面 创建、管理所有的访问秘钥对,且保证它处于“启用”状态。由于访问秘钥是阿里云对 API 请求进行安全验证的关键因子,请妥善保管你的访问秘钥。如果某些秘钥对出现泄漏风险,建议及时删除该秘钥对并生成新的替代秘钥对。

步骤 3 明确您业务场景中的AXN三元组中A和N分别对应的业务角色


AXN三元组中 A号码如果是客户的话,X号码就是为A客户分配的隐私号码,其他的任何号码拨打X号码都会转接到A号码,在创建AXN绑定关系时可以设定一个默认的B号码,假如A拨打X就会转接到这个B号码,如果B号码没有设置A就会被提示拨打的X号码是空号。

步骤 4 下载对应的SDK和DEMO样例程序编写代码


请到SDK&DEMO下载页面获取相应的SDK和DEMO程序,参照代码样例进行接口开发和调试。

参数



入参列表

参数名称参数类型必填与否样例取值参数说明
phoneNoAString必须15000000000AXN中的A号码
phoneNoBString可选15800000000AXN中的默认的B号码
noTypeString必须需要使用的号码类型目前支持2种号码类型,NO_95代表95接入号,NO_170代表170中间号
expirationDate必须2017-09-05 12:00:00绑定关系的过期时间
isRecordingEnabledBoolean可选true和false是否需要针对该绑定关系产生的所有通话录制通话录音
outIdString可选abcdef外部业务扩展字段


出参列表

出参名称出参类型样例取值参数说明
RequestIdString8906582E-6722请求ID
CodeStringOK状态码-返回OK代表请求成功,其他错误码详见错误码列表
MessageString请求成功状态码的描述
SecretBindDTOObject结构体绑定成功后返回的结构体,结构体的属性详见demo和SDK


技术对接步骤



1:下载SDK工具包


SDK工具包中一共包含了2个类库,一个aliyun-.net-sdk-core包,另外一个是alicom-dypls-api包,将这两个包执行mvn package命令或者mvn deploy命令打包出相应的jar包,添加到工程类库中依赖使用。
SDK&DEMO【下载地址】

2: 编写样例程序

  1. [backcolor=transparent]using[backcolor=transparent] [backcolor=transparent]System[backcolor=transparent];
  2. [backcolor=transparent]using[backcolor=transparent] [backcolor=transparent]System[backcolor=transparent].[backcolor=transparent]Collections[backcolor=transparent].[backcolor=transparent]Generic[backcolor=transparent];
  3. [backcolor=transparent]using[backcolor=transparent] [backcolor=transparent]System[backcolor=transparent].[backcolor=transparent]Text[backcolor=transparent];
  4. [backcolor=transparent]using[backcolor=transparent] [backcolor=transparent]Aliyun[backcolor=transparent].[backcolor=transparent]Acs[backcolor=transparent].[backcolor=transparent]Core[backcolor=transparent];
  5. [backcolor=transparent]using[backcolor=transparent] [backcolor=transparent]Aliyun[backcolor=transparent].[backcolor=transparent]Acs[backcolor=transparent].[backcolor=transparent]Core[backcolor=transparent].[backcolor=transparent]Exceptions[backcolor=transparent];
  6. [backcolor=transparent]using[backcolor=transparent] [backcolor=transparent]Aliyun[backcolor=transparent].[backcolor=transparent]Acs[backcolor=transparent].[backcolor=transparent]Core[backcolor=transparent].[backcolor=transparent]Profile[backcolor=transparent];
  7. [backcolor=transparent]using[backcolor=transparent] [backcolor=transparent]Aliyun[backcolor=transparent].[backcolor=transparent]Acs[backcolor=transparent].[backcolor=transparent]Dyplsapi[backcolor=transparent].[backcolor=transparent]Model[backcolor=transparent].[backcolor=transparent]V20170525[backcolor=transparent];
  8. [backcolor=transparent]using[backcolor=transparent] [backcolor=transparent]System[backcolor=transparent].[backcolor=transparent]Security[backcolor=transparent].[backcolor=transparent]Cryptography[backcolor=transparent];
  9. [backcolor=transparent]using[backcolor=transparent] [backcolor=transparent]System[backcolor=transparent].[backcolor=transparent]Threading[backcolor=transparent];
  10. [backcolor=transparent]namespace[backcolor=transparent] [backcolor=transparent]ConsoleApplication1
  11. [backcolor=transparent]{
  12. [backcolor=transparent]    [backcolor=transparent]class[backcolor=transparent] [backcolor=transparent]Program
  13. [backcolor=transparent]    [backcolor=transparent]{
  14. [backcolor=transparent]        [backcolor=transparent]//产品名称:云通信隐私保护API产品,开发者无需替换
  15. [backcolor=transparent]        [backcolor=transparent]const[backcolor=transparent] [backcolor=transparent]String[backcolor=transparent] product [backcolor=transparent]=[backcolor=transparent] [backcolor=transparent]"Dyplsapi"[backcolor=transparent];
  16. [backcolor=transparent]        [backcolor=transparent]//产品域名,开发者无需替换
  17. [backcolor=transparent]        [backcolor=transparent]const[backcolor=transparent] [backcolor=transparent]String[backcolor=transparent] domain [backcolor=transparent]=[backcolor=transparent] [backcolor=transparent]"dyplsapi.aliyuncs.com"[backcolor=transparent];
  18. [backcolor=transparent]        [backcolor=transparent]// TODO 此处需要替换成开发者自己的AK(在阿里云访问控制台寻找)
  19. [backcolor=transparent]        [backcolor=transparent]const[backcolor=transparent] [backcolor=transparent]String[backcolor=transparent] accessKeyId [backcolor=transparent]=[backcolor=transparent] [backcolor=transparent]"yourAccessKeyId"[backcolor=transparent];
  20. [backcolor=transparent]        [backcolor=transparent]const[backcolor=transparent] [backcolor=transparent]String[backcolor=transparent] accessKeySecret [backcolor=transparent]=[backcolor=transparent] [backcolor=transparent]"yourAccessKeySecret"[backcolor=transparent];[backcolor=transparent]      
  21. [backcolor=transparent]        [backcolor=transparent]public[backcolor=transparent] [backcolor=transparent]static[backcolor=transparent] [backcolor=transparent]BindAxnResponse[backcolor=transparent] bindAxn[backcolor=transparent]()
  22. [backcolor=transparent]        [backcolor=transparent]{
  23. [backcolor=transparent]            [backcolor=transparent]IClientProfile[backcolor=transparent] profile [backcolor=transparent]=[backcolor=transparent] [backcolor=transparent]DefaultProfile[backcolor=transparent].[backcolor=transparent]GetProfile[backcolor=transparent]([backcolor=transparent]"cn-hangzhou"[backcolor=transparent],[backcolor=transparent] accessKeyId[backcolor=transparent],[backcolor=transparent] accessKeySecret[backcolor=transparent]);
  24. [backcolor=transparent]            [backcolor=transparent]DefaultProfile[backcolor=transparent].[backcolor=transparent]AddEndpoint[backcolor=transparent]([backcolor=transparent]"cn-hangzhou"[backcolor=transparent],[backcolor=transparent] [backcolor=transparent]"cn-hangzhou"[backcolor=transparent],[backcolor=transparent] product[backcolor=transparent],[backcolor=transparent] domain[backcolor=transparent]);
  25. [backcolor=transparent]            [backcolor=transparent]IAcsClient[backcolor=transparent] client [backcolor=transparent]=[backcolor=transparent] [backcolor=transparent]new[backcolor=transparent] [backcolor=transparent]DefaultAcsClient[backcolor=transparent]([backcolor=transparent]profile[backcolor=transparent]);
  26. [backcolor=transparent]            [backcolor=transparent]BindAxnRequest[backcolor=transparent] request [backcolor=transparent]=[backcolor=transparent] [backcolor=transparent]new[backcolor=transparent] [backcolor=transparent]BindAxnRequest[backcolor=transparent]();
  27. [backcolor=transparent]            request[backcolor=transparent].[backcolor=transparent]PhoneNoA[backcolor=transparent] [backcolor=transparent]=[backcolor=transparent] [backcolor=transparent]"15010101010"[backcolor=transparent];
  28. [backcolor=transparent]            request[backcolor=transparent].[backcolor=transparent]PhoneNoB[backcolor=transparent] [backcolor=transparent]=[backcolor=transparent] [backcolor=transparent]"15020202020"[backcolor=transparent];
  29. [backcolor=transparent]            request[backcolor=transparent].[backcolor=transparent]Expiration[backcolor=transparent] [backcolor=transparent]=[backcolor=transparent] [backcolor=transparent]"2017-09-18 17:00:00"[backcolor=transparent];
  30. [backcolor=transparent]            [backcolor=transparent]//可选:是否需要录制音频-默认是false
  31. [backcolor=transparent]            request[backcolor=transparent].[backcolor=transparent]IsRecordingEnabled[backcolor=transparent] [backcolor=transparent]=[backcolor=transparent] [backcolor=transparent]false[backcolor=transparent];
  32. [backcolor=transparent]            [backcolor=transparent]//外部业务自定义ID属性
  33. [backcolor=transparent]            request[backcolor=transparent].[backcolor=transparent]OutId[backcolor=transparent] [backcolor=transparent]=[backcolor=transparent] [backcolor=transparent]"yourOutId"[backcolor=transparent];
  34. [backcolor=transparent]            [backcolor=transparent]//AXN的隐私号码X一共支持2种号码类型 NO_95 NO_170
  35. [backcolor=transparent]            request[backcolor=transparent].[backcolor=transparent]NoType[backcolor=transparent] [backcolor=transparent]=[backcolor=transparent] [backcolor=transparent]"NO_95"[backcolor=transparent];
  36. [backcolor=transparent]            [backcolor=transparent]BindAxnResponse[backcolor=transparent] response [backcolor=transparent]=[backcolor=transparent] [backcolor=transparent]null[backcolor=transparent];
  37. [backcolor=transparent]            [backcolor=transparent]try
  38. [backcolor=transparent]            [backcolor=transparent]{
  39. [backcolor=transparent]                response [backcolor=transparent]=[backcolor=transparent] client[backcolor=transparent].[backcolor=transparent]GetAcsResponse[backcolor=transparent]([backcolor=transparent]request[backcolor=transparent]);
  40. [backcolor=transparent]            [backcolor=transparent]}
  41. [backcolor=transparent]            [backcolor=transparent]catch[backcolor=transparent] [backcolor=transparent]([backcolor=transparent]ServerException[backcolor=transparent] e[backcolor=transparent])
  42. [backcolor=transparent]            [backcolor=transparent]{
  43. [backcolor=transparent]            [backcolor=transparent]}
  44. [backcolor=transparent]            [backcolor=transparent]catch[backcolor=transparent] [backcolor=transparent]([backcolor=transparent]ClientException[backcolor=transparent] e[backcolor=transparent])
  45. [backcolor=transparent]            [backcolor=transparent]{
  46. [backcolor=transparent]            [backcolor=transparent]}
  47. [backcolor=transparent]            [backcolor=transparent]return[backcolor=transparent] response[backcolor=transparent];
  48. [backcolor=transparent]        [backcolor=transparent]}
  49. [backcolor=transparent]        [backcolor=transparent]static[backcolor=transparent] [backcolor=transparent]void[backcolor=transparent] [backcolor=transparent]Main[backcolor=transparent]([backcolor=transparent]string[backcolor=transparent][][backcolor=transparent] args[backcolor=transparent])
  50. [backcolor=transparent]        [backcolor=transparent]{
  51. [backcolor=transparent]            [backcolor=transparent]BindAxnResponse[backcolor=transparent] axnResponse [backcolor=transparent]=[backcolor=transparent] bindAxn[backcolor=transparent]();
  52. [backcolor=transparent]            [backcolor=transparent]Console[backcolor=transparent].[backcolor=transparent]Write[backcolor=transparent]([backcolor=transparent]"AXN绑定接口返回的结果----------------"[backcolor=transparent]);
  53. [backcolor=transparent]            [backcolor=transparent]Console[backcolor=transparent].[backcolor=transparent]Write[backcolor=transparent]([backcolor=transparent]"Code="[backcolor=transparent] [backcolor=transparent]+[backcolor=transparent] axnResponse[backcolor=transparent].[backcolor=transparent]Code[backcolor=transparent]);
  54. [backcolor=transparent]            [backcolor=transparent]Console[backcolor=transparent].[backcolor=transparent]Write[backcolor=transparent]([backcolor=transparent]"Message="[backcolor=transparent] [backcolor=transparent]+[backcolor=transparent] axnResponse[backcolor=transparent].[backcolor=transparent]Message[backcolor=transparent]);
  55. [backcolor=transparent]            [backcolor=transparent]Console[backcolor=transparent].[backcolor=transparent]Write[backcolor=transparent]([backcolor=transparent]"RequestId="[backcolor=transparent] [backcolor=transparent]+[backcolor=transparent] axnResponse[backcolor=transparent].[backcolor=transparent]RequestId[backcolor=transparent]);
  56. [backcolor=transparent]            [backcolor=transparent]String[backcolor=transparent] axnSubsId [backcolor=transparent]=[backcolor=transparent] axnResponse[backcolor=transparent].[backcolor=transparent]SecretBindDTO[backcolor=transparent] [backcolor=transparent]==[backcolor=transparent] [backcolor=transparent]null[backcolor=transparent] [backcolor=transparent]?[backcolor=transparent] [backcolor=transparent]null[backcolor=transparent] [backcolor=transparent]:[backcolor=transparent] axnResponse[backcolor=transparent].[backcolor=transparent]SecretBindDTO[backcolor=transparent].[backcolor=transparent]SubsId[backcolor=transparent];
  57. [backcolor=transparent]            [backcolor=transparent]String[backcolor=transparent] axnSecretNo [backcolor=transparent]=[backcolor=transparent] axnResponse[backcolor=transparent].[backcolor=transparent]SecretBindDTO[backcolor=transparent] [backcolor=transparent]==[backcolor=transparent] [backcolor=transparent]null[backcolor=transparent] [backcolor=transparent]?[backcolor=transparent] [backcolor=transparent]null[backcolor=transparent] [backcolor=transparent]:[backcolor=transparent] axnResponse[backcolor=transparent].[backcolor=transparent]SecretBindDTO[backcolor=transparent].[backcolor=transparent]SecretNo[backcolor=transparent];
  58. [backcolor=transparent]            [backcolor=transparent]Console[backcolor=transparent].[backcolor=transparent]Write[backcolor=transparent]([backcolor=transparent]"subsId="[backcolor=transparent] [backcolor=transparent]+[backcolor=transparent] axnSubsId[backcolor=transparent]);
  59. [backcolor=transparent]            [backcolor=transparent]Console[backcolor=transparent].[backcolor=transparent]Write[backcolor=transparent]([backcolor=transparent]"secretNo="[backcolor=transparent] [backcolor=transparent]+[backcolor=transparent] axnSecretNo[backcolor=transparent]);
  60. [backcolor=transparent]            [backcolor=transparent]Console[backcolor=transparent].[backcolor=transparent]WriteLine[backcolor=transparent]();[backcolor=transparent]                  
  61. [backcolor=transparent]        [backcolor=transparent]}
  62. [backcolor=transparent]    [backcolor=transparent]}
  63. [backcolor=transparent]}


错误码列表

Code描述
OK请求成功
isp.RAM_PERMISSION_DENYRAM权限DENY
isv.OUT_OF_SERVICE业务停机
isv.PRODUCT_UN_SUBSCRIPT未开通云通信产品的阿里云客户
isv.PRODUCT_UNSUBSCRIBE产品未开通
isv.ACCOUNT_NOT_EXISTS账户不存在
isv.ACCOUNT_ABNORMAL账户异常
isp.SYSTEM_ERROR系统错误
isp.UNKNOWN_ERR_CODE运营商未知错误
isv.PARTNER_NOT_EXIST未知合作伙伴
isv.NO_NOT_EXIST号码不存在
isv.ILLEGAL_ARGUMENT参数非法
isp.DAO_EXCEPTION数据库异常
isv.NO_AVAILABLE_NUMBER无可用号码
isp.VENDOR_UNAVAILABLE运营商降级
isv.FLOW_LIMIT业务流控
isv.PARTNER_IS_CLOSEDpartner被关停
isv.FORBIDDEN_ACTION无权操作
isv.NO_USED_BY_OTHERS码被其他业务方占用
isv.VENDOR_BIND_FAILED运营商绑定失败
isv.EXPIRE_DATE_ILLEGAL过期时间非法
isv.MOBILE_NUMBER_ILLEGAL号码格式非法
isv.BIND_CONFLICT绑定冲突

展开
收起
猫饭先生 2017-10-25 14:25:53 1684 0
0 条回答
写回答
取消 提交回答
问答排行榜
最热
最新

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载