======1. 接口对接======
注意: 为了确保数据隐私和安全, REST API须通过HTTPS方式请求(查询子账号信息接口除外)
-注意: 请使用开发者账号、密码登录BSS.UCPAAS.COM申请语音通知模板
**URL请求方式及地址** \\ 请求方式:POST 请求地址:https://message.ucpaas.com/{version}/Accounts/{accountSid}/Calls/voiceNotify?sig={SigParameter} **URL参数属性说明** \\ {| !style="width:100%;","text-align:center;" ! |属性 ! |说明 |- |Version |云之讯REST API版本号,当前版本号为:2014-06-30 |- |Account |此参数为默认固定值 |- |accountSid |注册云之讯官网,在控制台中即可获取此参数 |- |Calls |业务功能 |- |voiceNotify |业务操作,业务功能的各类具体操作分支 |- |SigParameter |请求URL必须带有此参数 |- |} **** {| !style="width:100%;","text-align:center;" |Accept |客户端响应接收数据格式:application/xml、application/json |- |Content-Type |类型:application/xml;charset=utf-8、application/json;charset=utf-8 |- |Authorization |验证信息 |- |Content-Length |包体长度 |- |} **关键点** SigParameter是REST API 验证参数 URL后必须带有sig参数,sig= MD5(账户Id + 账户授权令牌 + 时间戳),共32位(注:转成大写) 使用MD5加密(账户Id + 账户授权令牌 + 时间戳),共32位 时间戳是当前系统时间(24小时制),格式“yyyyMMddHHmmss”。时间戳有效时间为50分钟。 Authorization是包头验证信息 使用Base64编码(账户Id + 冒号 + 时间戳) 冒号为英文冒号 时间戳是当前系统时间(24小时制),格式“yyyyMMddHHmmss”,需与SigParameter中时间戳相同 ======2.语音通知发送接口—API====== ===请求参数说明=== {| !style="width:100%;","text-align:center;" ! |属性 ! |类型 ! |约束 ! |说明 |- |appId |String |必选 |应用Id |- |to |String |必选 |被叫号码 |- |toSerNum |String |可选 |语音通知的被叫侧显示的号码 |- |type |String |必选 |2{文字模板} |- |playTimes |String |可选 |语音通知播放次数,默认是1次 |- |templateId |String |必选 |模板ID |- |content |String |必选 |模板参数值,形式为json格式,如{"var1":"aa","var2":"bb"} |- |billUrl |String |可选 |话单推送url |- |userData |String |可选 |用户自定义透传字段 |- |} ===请求响应参数说明=== {| !style="width:100%;","text-align:center;" ! |属性 ! |类型 ! |约束 ! |说明 |- |respCode |String |必选 |请求返回的状态码 00000代表成功 |- |callId |String |必选 |用户唯一通话标识长度不能超过32 |- |createDate |String |必选 |语音通知发起时间,格式yyyyMMddHHmmss |- |}
POST/2014-06-30/Accounts/e03bc9106c6ed0eaebfce8c368fdcd48/Calls/voiceNotify? sig=4D3C2549D3A487841CB3D84EA7421FCD
Host:api.ucpaas.com
Accept:application/json
Content-Type:application/json;charset=utf-8
Authorization:ZTAzYmM5MTA2YzZlZDBlYWViZmNlOGMzNjhmZGNkNDg6MjAxNDA2MjMxODQ3MzQ=
{
"voiceNotify":
{
"appId":"6gfsjdgfdsjgsjc4193a0c6756962eaefa0",
"to":"15947895641",
"type":"2",
"content":"{\"var1\":\"aa\",\"var2\":\"bb \"}",
"toSerNum":"057112345678",
"playTimes":"2",
"userData":"12\u0026h",
"billUrl":"http://www.bill.com/bill",
"templateId":"1001"
}
}
正确响应包体
{"resp":{
"respCode":"000000",
"voiceNotify":{
"callId":"d9ace77d8b1929d8ff9517987a87b96b",
"createDate":"20170223165806"}
}
}
错误响应包体
{"resp":{
"respCode":"104155"
}
}
POST /voicenotify HTTP/1.1
Host: 127.0.0.1:152
Content-Type:application/json
Accept:application/json
Connection:close
Content-Length: 290
{
"callId": "0ecedf7844549aecd23589bea3faf3bf",
"requestId": "fcfb636d25c34704b93ca4691f98ad0f",
"caller": "057912345678",
"callee": "13111111111",
"accountid": "d9845c6e97d20f539e8d9d2488567d65",
"appid": "7e4d7873001093e34cb322fdc52ffd02",
"event": "saleCall",
"duration": 6,
"state": 0
}
HTTP/1.1 200 OK
Content-length: 121
Date: Thu, 23 Feb 2017 09:32:54 GMT
{
"callId": "0ecedf7844549aecd23589bea3faf3bf",
"respCode": "000000",
"message": "success"
}