开发者社区> 问答> 正文

号码隐私保护



简介


当您使用隐私号码服务绑定一组AXB(或者AXN、以下统一以AXB为代表说明)隐私关系后,可以通过使用MNS的Queue模型来接收话单回执消息,话单回执消息时记录了AXB三元组发生的所有的通话记录行为。

消息的订阅


云通信的所有业务消息都用过MNS消息服务向外发送。用户每订阅一个类别的消息(比如隐私号码话单回执消息(SecretReport),系统都会为用户分配一个独立的消息队列。用户可以通过阿里云账号拿到一个临时的token用于获取队列中的消息。用户可以下载demo,编写简单的消息处理类即可完成消息处理的任务。在页面上订阅消息,订阅完消息后,能拿到消息队列名称(queueName)。比如:Alicom-Queue-xxxxxx-SecretReport 。队列名字每个用户都不同。

消息类型


隐私号码目前提供一种消息类型,话单回执消息SecretReport

流量充值回执消息FlowReport消息体格式

名称类型描述示例是否必须
sub_idString通话对应的三元组的绑定关系ID123456必须
call_idString唯一标识一通通话记录的IDabcdef1234必须
phone_noStringAXB中的A号码15000000000必须
secret_noStringAXB中的X号码1700000000必须
peer_noStringAXB中的B号码或者N号码1580000000必须
call_typeNumber呼叫类型0:主叫(phone_no打给peer_no);1:被叫(peer_no打给phone_no);2:短信发送;3:短信接收必须
call_timeDate呼叫动作开始时间“2017-09-01 12:00:00”必须
ring_timeDate对端手机振铃时间“2017-09-01 12:01:00”必须
start_timeDate对端接听时间“2017-09-01 12:01:00”必须
release_timeDate对端挂断时间,release_time - start_time 代表通话时长 如果结果为0,代表呼叫未接通“2017-09-01 12:02:00”必须
release_dirNumber通话释放方向0 ,1 ,2 ,3必须


技术对接步骤



下载消息SDK


下载对应语音的消息DEMO工程,工程所需要的所有依赖jar包都放在DEMO工程的lib目录下,将对于的jar包引入到您的工程当中既可按照DEMO样例编写接收消息的程序。
SDK&DEMO【下载地址】

样例

  1. [backcolor=transparent]/**
  2. [backcolor=transparent] * 只能用于接收云通信的消息,不能用于接收其他业务的消息
  3. [backcolor=transparent] */
  4. [backcolor=transparent]public[backcolor=transparent] [backcolor=transparent]class[backcolor=transparent] [backcolor=transparent]ReceiveAlicomMsgDemo[backcolor=transparent] [backcolor=transparent]{
  5. [backcolor=transparent]    [backcolor=transparent]private[backcolor=transparent] [backcolor=transparent]static[backcolor=transparent] [backcolor=transparent]Log[backcolor=transparent] logger[backcolor=transparent]=[backcolor=transparent]LogFactory[backcolor=transparent].[backcolor=transparent]getLog[backcolor=transparent]([backcolor=transparent]ReceiveAlicomMsgDemo[backcolor=transparent].[backcolor=transparent]class[backcolor=transparent]);
  6. [backcolor=transparent]    [backcolor=transparent]static[backcolor=transparent] [backcolor=transparent]class[backcolor=transparent] [backcolor=transparent]MyMessageListener[backcolor=transparent] [backcolor=transparent]implements[backcolor=transparent] [backcolor=transparent]MessageListener[backcolor=transparent]{
  7. [backcolor=transparent]        [backcolor=transparent]private[backcolor=transparent] [backcolor=transparent]Gson[backcolor=transparent] gson[backcolor=transparent]=[backcolor=transparent]new[backcolor=transparent] [backcolor=transparent]Gson[backcolor=transparent]();
  8. [backcolor=transparent]        [backcolor=transparent]@Override
  9. [backcolor=transparent]        [backcolor=transparent]public[backcolor=transparent] [backcolor=transparent]boolean[backcolor=transparent] dealMessage[backcolor=transparent]([backcolor=transparent]Message[backcolor=transparent] message[backcolor=transparent])[backcolor=transparent] [backcolor=transparent]{
  10. [backcolor=transparent]            [backcolor=transparent]System[backcolor=transparent].[backcolor=transparent]out[backcolor=transparent].[backcolor=transparent]println[backcolor=transparent]([backcolor=transparent]"message handle: "[backcolor=transparent] [backcolor=transparent]+[backcolor=transparent] message[backcolor=transparent].[backcolor=transparent]getReceiptHandle[backcolor=transparent]());
  11. [backcolor=transparent]            [backcolor=transparent]System[backcolor=transparent].[backcolor=transparent]out[backcolor=transparent].[backcolor=transparent]println[backcolor=transparent]([backcolor=transparent]"message body: "[backcolor=transparent] [backcolor=transparent]+[backcolor=transparent] message[backcolor=transparent].[backcolor=transparent]getMessageBodyAsString[backcolor=transparent]());
  12. [backcolor=transparent]            [backcolor=transparent]System[backcolor=transparent].[backcolor=transparent]out[backcolor=transparent].[backcolor=transparent]println[backcolor=transparent]([backcolor=transparent]"message id: "[backcolor=transparent] [backcolor=transparent]+[backcolor=transparent] message[backcolor=transparent].[backcolor=transparent]getMessageId[backcolor=transparent]());
  13. [backcolor=transparent]            [backcolor=transparent]System[backcolor=transparent].[backcolor=transparent]out[backcolor=transparent].[backcolor=transparent]println[backcolor=transparent]([backcolor=transparent]"message dequeue count:"[backcolor=transparent] [backcolor=transparent]+[backcolor=transparent] message[backcolor=transparent].[backcolor=transparent]getDequeueCount[backcolor=transparent]());
  14. [backcolor=transparent]            [backcolor=transparent]try[backcolor=transparent]{
  15. [backcolor=transparent]                [backcolor=transparent]Map[backcolor=transparent]<[backcolor=transparent]String[backcolor=transparent],[backcolor=transparent]Object[backcolor=transparent]>[backcolor=transparent] contentMap[backcolor=transparent]=[backcolor=transparent]gson[backcolor=transparent].[backcolor=transparent]fromJson[backcolor=transparent]([backcolor=transparent]message[backcolor=transparent].[backcolor=transparent]getMessageBodyAsString[backcolor=transparent](),[backcolor=transparent] [backcolor=transparent]HashMap[backcolor=transparent].[backcolor=transparent]class[backcolor=transparent]);
  16. [backcolor=transparent]                [backcolor=transparent]String[backcolor=transparent] phone[backcolor=transparent]=([backcolor=transparent]String[backcolor=transparent])[backcolor=transparent]contentMap[backcolor=transparent].[backcolor=transparent]get[backcolor=transparent]([backcolor=transparent]"phone"[backcolor=transparent]);
  17. [backcolor=transparent]                [backcolor=transparent]Boolean[backcolor=transparent] outId[backcolor=transparent]=([backcolor=transparent]Boolean[backcolor=transparent])[backcolor=transparent]contentMap[backcolor=transparent].[backcolor=transparent]get[backcolor=transparent]([backcolor=transparent]"out_id"[backcolor=transparent]);
  18. [backcolor=transparent]                [backcolor=transparent]String[backcolor=transparent] result[backcolor=transparent]=([backcolor=transparent]String[backcolor=transparent])[backcolor=transparent]contentMap[backcolor=transparent].[backcolor=transparent]get[backcolor=transparent]([backcolor=transparent]"result"[backcolor=transparent]);
  19. [backcolor=transparent]                [backcolor=transparent]String[backcolor=transparent] errCode[backcolor=transparent]=([backcolor=transparent]String[backcolor=transparent])[backcolor=transparent]contentMap[backcolor=transparent].[backcolor=transparent]get[backcolor=transparent]([backcolor=transparent]"err_code"[backcolor=transparent]);
  20. [backcolor=transparent]                [backcolor=transparent]String[backcolor=transparent] errMsg[backcolor=transparent]=([backcolor=transparent]String[backcolor=transparent])[backcolor=transparent]contentMap[backcolor=transparent].[backcolor=transparent]get[backcolor=transparent]([backcolor=transparent]"err_msg"[backcolor=transparent]);
  21. [backcolor=transparent]                [backcolor=transparent]//TODO 这里开始写业务代码
  22. [backcolor=transparent]            [backcolor=transparent]}[backcolor=transparent]catch[backcolor=transparent]([backcolor=transparent]com[backcolor=transparent].[backcolor=transparent]google[backcolor=transparent].[backcolor=transparent]gson[backcolor=transparent].[backcolor=transparent]JsonSyntaxException[backcolor=transparent] e[backcolor=transparent]){
  23. [backcolor=transparent]                logger[backcolor=transparent].[backcolor=transparent]error[backcolor=transparent]([backcolor=transparent]"error_json_format:"[backcolor=transparent]+[backcolor=transparent]message[backcolor=transparent].[backcolor=transparent]getMessageBodyAsString[backcolor=transparent](),[backcolor=transparent]e[backcolor=transparent]);
  24. [backcolor=transparent]            [backcolor=transparent]}
  25. [backcolor=transparent]            [backcolor=transparent]Boolean[backcolor=transparent] dealResult[backcolor=transparent]=[backcolor=transparent]true[backcolor=transparent];
  26. [backcolor=transparent]            [backcolor=transparent]return[backcolor=transparent] dealResult[backcolor=transparent];[backcolor=transparent]//返回true,则工具类自动删除已拉取的消息。
  27. [backcolor=transparent]        [backcolor=transparent]}
  28. [backcolor=transparent]    [backcolor=transparent]}
  29. [backcolor=transparent]    [backcolor=transparent]public[backcolor=transparent] [backcolor=transparent]static[backcolor=transparent] [backcolor=transparent]void[backcolor=transparent] main[backcolor=transparent]([backcolor=transparent]String[backcolor=transparent][][backcolor=transparent] args[backcolor=transparent])[backcolor=transparent] [backcolor=transparent]throws[backcolor=transparent] com[backcolor=transparent].[backcolor=transparent]aliyuncs[backcolor=transparent].[backcolor=transparent]exceptions[backcolor=transparent].[backcolor=transparent]ClientException[backcolor=transparent],[backcolor=transparent] [backcolor=transparent]ParseException[backcolor=transparent] [backcolor=transparent]{
  30. [backcolor=transparent]        [backcolor=transparent]DefaultAlicomMessagePuller[backcolor=transparent] puller[backcolor=transparent]=[backcolor=transparent]new[backcolor=transparent] [backcolor=transparent]DefaultAlicomMessagePuller[backcolor=transparent]();
  31. [backcolor=transparent]        [backcolor=transparent]String[backcolor=transparent] accessKeyId[backcolor=transparent]=[backcolor=transparent]"yourAccessKeyId"[backcolor=transparent];
  32. [backcolor=transparent]        [backcolor=transparent]String[backcolor=transparent] accessKeySecret[backcolor=transparent]=[backcolor=transparent]"yourAccessKeySecret"[backcolor=transparent];
  33. [backcolor=transparent]        [backcolor=transparent]String[backcolor=transparent] messageType[backcolor=transparent]=[backcolor=transparent]"SecretReport"[backcolor=transparent];
  34. [backcolor=transparent]        [backcolor=transparent]String[backcolor=transparent] queueName[backcolor=transparent]=[backcolor=transparent]"Alicom-queue-xxxxxx-SecretReport"[backcolor=transparent];[backcolor=transparent]//在云通信页面开通相应业务消息后,就能在页面上获得对应的queueName
  35. [backcolor=transparent]        puller[backcolor=transparent].[backcolor=transparent]startReceiveMsg[backcolor=transparent]([backcolor=transparent]accessKeyId[backcolor=transparent],[backcolor=transparent]accessKeySecret [backcolor=transparent],[backcolor=transparent]messageType[backcolor=transparent],[backcolor=transparent]queueName [backcolor=transparent],[backcolor=transparent] [backcolor=transparent]new[backcolor=transparent] [backcolor=transparent]MyMessageListener[backcolor=transparent]());
  36. [backcolor=transparent]    [backcolor=transparent]}
  37. [backcolor=transparent]}

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

相关电子书

更多
阿里小号隐私保护 立即下载
低代码开发师(初级)实战教程 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载