为方便其它语言能快速实现,在此增加了HTTP的详解
注:云通信下的三类产品(包括短信、语音、流量),接口协议一致
一、前言说明
三类产品平台都提供了调用API和消息回执的交互 举例如:
- 通过调用语音呼叫API,例如文本转语音外呼接口,来成功发起呼叫。
平台成功收到请求后发送给运营商,等用户最终挂断电话后,平台会有最终的状态消息确认,就是消息回执对应的协议是:
- 发送API采用Rest协议:签名算法使用了阿里云的POP协议
- 发送后消息回执:采用的是阿里云的消息中间件MNS来实现
二、协议说明
由于POP的签名算法比较复杂,下面这里结合文本转语音的接口一并详细说明
2.1 文本转语音API的HTTP协议包示例
请求示例:
- [backcolor=transparent]GET [backcolor=transparent]/?[backcolor=transparent]Signature[backcolor=transparent]=[backcolor=transparent]ACaeddgMkXN[backcolor=transparent]%[backcolor=transparent]2FRu7[backcolor=transparent]%[backcolor=transparent]2BnpPqvgY[backcolor=transparent]%[backcolor=transparent]2Fyl4[backcolor=transparent]%[backcolor=transparent]3D[backcolor=transparent]&[backcolor=transparent]AccessKeyId[backcolor=transparent]=[backcolor=transparent]LTAIF0IDDKoh1Ra0[backcolor=transparent]&[backcolor=transparent]Action[backcolor=transparent]=[backcolor=transparent]SingleCallByTts[backcolor=transparent]&[backcolor=transparent]CalledNumber[backcolor=transparent]=[backcolor=transparent]13000000000[backcolor=transparent]&[backcolor=transparent]CalledShowNumber[backcolor=transparent]=[backcolor=transparent]057112345678[backcolor=transparent]&[backcolor=transparent]Format[backcolor=transparent]=[backcolor=transparent]XML[backcolor=transparent]&[backcolor=transparent]OutId[backcolor=transparent]=[backcolor=transparent]123[backcolor=transparent]&[backcolor=transparent]RegionId[backcolor=transparent]=[backcolor=transparent]cn[backcolor=transparent]-[backcolor=transparent]hangzhou[backcolor=transparent]&[backcolor=transparent]SignatureMethod[backcolor=transparent]=[backcolor=transparent]HMAC[backcolor=transparent]-[backcolor=transparent]SHA1[backcolor=transparent]&[backcolor=transparent]SignatureNonce[backcolor=transparent]=[backcolor=transparent]50f16c4d[backcolor=transparent]-[backcolor=transparent]a91c[backcolor=transparent]-[backcolor=transparent]4a5a[backcolor=transparent]-[backcolor=transparent]b17b[backcolor=transparent]-[backcolor=transparent]7a391362e636[backcolor=transparent]&[backcolor=transparent]SignatureVersion[backcolor=transparent]=[backcolor=transparent]1.0[backcolor=transparent]&[backcolor=transparent]Timestamp[backcolor=transparent]=[backcolor=transparent]2017[backcolor=transparent]-[backcolor=transparent]09[backcolor=transparent]-[backcolor=transparent]28T14[backcolor=transparent]%[backcolor=transparent]3A21[backcolor=transparent]%[backcolor=transparent]3A37Z[backcolor=transparent]&[backcolor=transparent]TtsCode[backcolor=transparent]=[backcolor=transparent]TTS_0000000[backcolor=transparent]&[backcolor=transparent]TtsParam[backcolor=transparent]=%[backcolor=transparent]7B[backcolor=transparent]%[backcolor=transparent]22code[backcolor=transparent]%[backcolor=transparent]22[backcolor=transparent]%[backcolor=transparent]3A[backcolor=transparent]%[backcolor=transparent]221234[backcolor=transparent]%[backcolor=transparent]22[backcolor=transparent]%[backcolor=transparent]2C[backcolor=transparent]%[backcolor=transparent]22product[backcolor=transparent]%[backcolor=transparent]22[backcolor=transparent]%[backcolor=transparent]3A[backcolor=transparent]%[backcolor=transparent]22test[backcolor=transparent]%[backcolor=transparent]22[backcolor=transparent]%[backcolor=transparent]7D[backcolor=transparent]&[backcolor=transparent]Version[backcolor=transparent]=[backcolor=transparent]2017[backcolor=transparent]-[backcolor=transparent]05[backcolor=transparent]-[backcolor=transparent]25
- [backcolor=transparent]HTTP[backcolor=transparent]/[backcolor=transparent]1.1
- [backcolor=transparent]Host[backcolor=transparent]:[backcolor=transparent] dyvmsapi[backcolor=transparent].[backcolor=transparent]aliyuncs[backcolor=transparent].[backcolor=transparent]com
- [backcolor=transparent]...
返回示例:
- [backcolor=transparent]HTTP[backcolor=transparent]/[backcolor=transparent]1.1[backcolor=transparent] [backcolor=transparent]200[backcolor=transparent] OK
- [backcolor=transparent]...
- [backcolor=transparent]<?[backcolor=transparent]xml version[backcolor=transparent]=[backcolor=transparent]'1.0'[backcolor=transparent] encoding[backcolor=transparent]=[backcolor=transparent]'UTF-8'[backcolor=transparent]?>
- [backcolor=transparent]<[backcolor=transparent]SingleCallByTtsResponse[backcolor=transparent]>
- [backcolor=transparent]<[backcolor=transparent]Message[backcolor=transparent]>[backcolor=transparent]OK[backcolor=transparent]</[backcolor=transparent]Message[backcolor=transparent]>
- [backcolor=transparent]<[backcolor=transparent]RequestId[backcolor=transparent]>[backcolor=transparent]220F7831[backcolor=transparent]-[backcolor=transparent]A8A9[backcolor=transparent]-[backcolor=transparent]4A7F[backcolor=transparent]-[backcolor=transparent]9A55[backcolor=transparent]-[backcolor=transparent]272346F61B14[backcolor=transparent]</[backcolor=transparent]RequestId[backcolor=transparent]>
- [backcolor=transparent]<[backcolor=transparent]Code[backcolor=transparent]>[backcolor=transparent]OK[backcolor=transparent]</[backcolor=transparent]Code[backcolor=transparent]>
- [backcolor=transparent]<[backcolor=transparent]CallId[backcolor=transparent]>[backcolor=transparent]113277672277[backcolor=transparent]^[backcolor=transparent]100610220432[backcolor=transparent]</[backcolor=transparent]CallId[backcolor=transparent]>
- [backcolor=transparent]</[backcolor=transparent]SingleCallByTtsResponse[backcolor=transparent]>
2.2 文本转语音Rest请求参数
如HTTP示例包中,请求的参数可以分两大块:系统参数 和 业务参数
系统参数
系统参数为POP协议的基本参数,有
业务参数
[tr=rgb(239, 251, 255)][td]TtsCode
是 | 具体见API文档描述 |
TtsParam | 否 | 具体见API文档描述 |
OutId | 否 | 具体见API文档描述 |