为方便其它语言能快速实现,在此增加了HTTP的详解
注:云通信下的三类产品(包括短信、语音、流量),接口协议一致
一、前言说明
三类产品平台都提供了调用API和消息回执的交互 举例如:
- 通过调用短信的发送API,来成功发送短信
平台成功收到请求后发送给运营商,等用户最终收到短信后,平台会有最终的状态消息确认,就是消息回执
对应的协议是:
- 发送API采用Rest协议:签名算法使用了阿里云的POP协议
- 发送后消息回执:采用的是阿里云的消息中间件MNS来实现
二、协议说明
由于POP的签名算法比较复杂,下面这里结合短信的发送API一并详细说明
2.1 短信发送API的HTTP协议包示例
请求示例:
- [backcolor=transparent]GET [backcolor=transparent]/?[backcolor=transparent]Signature[backcolor=transparent]=[backcolor=transparent]zJDF[backcolor=transparent]%[backcolor=transparent]2BLrzhj[backcolor=transparent]%[backcolor=transparent]2FThnlvIToysFRq6t4[backcolor=transparent]%[backcolor=transparent]3D[backcolor=transparent]&[backcolor=transparent]AccessKeyId[backcolor=transparent]=[backcolor=transparent]testId[backcolor=transparent]&[backcolor=transparent]Action[backcolor=transparent]=[backcolor=transparent]SendSms[backcolor=transparent]&[backcolor=transparent]Format[backcolor=transparent]=[backcolor=transparent]XML[backcolor=transparent]&[backcolor=transparent]OutId[backcolor=transparent]=[backcolor=transparent]123[backcolor=transparent]&[backcolor=transparent]PhoneNumbers[backcolor=transparent]=[backcolor=transparent]15300000001[backcolor=transparent]&[backcolor=transparent]RegionId[backcolor=transparent]=[backcolor=transparent]cn[backcolor=transparent]-[backcolor=transparent]hangzhou[backcolor=transparent]&[backcolor=transparent]SignName[backcolor=transparent]=%[backcolor=transparent]E9[backcolor=transparent]%[backcolor=transparent]98[backcolor=transparent]%[backcolor=transparent]BF[backcolor=transparent]%[backcolor=transparent]E9[backcolor=transparent]%[backcolor=transparent]87[backcolor=transparent]%[backcolor=transparent]8C[backcolor=transparent]%[backcolor=transparent]E4[backcolor=transparent]%[backcolor=transparent]BA[backcolor=transparent]%[backcolor=transparent]91[backcolor=transparent]%[backcolor=transparent]E7[backcolor=transparent]%[backcolor=transparent]9F[backcolor=transparent]%[backcolor=transparent]AD[backcolor=transparent]%[backcolor=transparent]E4[backcolor=transparent]%[backcolor=transparent]BF[backcolor=transparent]%[backcolor=transparent]A1[backcolor=transparent]%[backcolor=transparent]E6[backcolor=transparent]%[backcolor=transparent]B5[backcolor=transparent]%[backcolor=transparent]8B[backcolor=transparent]%[backcolor=transparent]E8[backcolor=transparent]%[backcolor=transparent]AF[backcolor=transparent]%[backcolor=transparent]95[backcolor=transparent]%[backcolor=transparent]E4[backcolor=transparent]%[backcolor=transparent]B8[backcolor=transparent]%[backcolor=transparent]93[backcolor=transparent]%[backcolor=transparent]E7[backcolor=transparent]%[backcolor=transparent]94[backcolor=transparent]%[backcolor=transparent]A8[backcolor=transparent]&[backcolor=transparent]SignatureMethod[backcolor=transparent]=[backcolor=transparent]HMAC[backcolor=transparent]-[backcolor=transparent]SHA1[backcolor=transparent]&[backcolor=transparent]SignatureNonce[backcolor=transparent]=[backcolor=transparent]45e25e9b[backcolor=transparent]-[backcolor=transparent]0a6f[backcolor=transparent]-[backcolor=transparent]4070[backcolor=transparent]-[backcolor=transparent]8c85[backcolor=transparent]-[backcolor=transparent]2956eda1b466[backcolor=transparent]&[backcolor=transparent]SignatureVersion[backcolor=transparent]=[backcolor=transparent]1.0[backcolor=transparent]&[backcolor=transparent]TemplateCode[backcolor=transparent]=[backcolor=transparent]SMS_71390007[backcolor=transparent]&[backcolor=transparent]TemplateParam[backcolor=transparent]=%[backcolor=transparent]7B[backcolor=transparent]%[backcolor=transparent]22customer[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]Timestamp[backcolor=transparent]=[backcolor=transparent]2017[backcolor=transparent]-[backcolor=transparent]07[backcolor=transparent]-[backcolor=transparent]12T02[backcolor=transparent]%[backcolor=transparent]3A42[backcolor=transparent]%[backcolor=transparent]3A19Z[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] dysmsapi[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]SendSmsResponse[backcolor=transparent]><[backcolor=transparent]Message[backcolor=transparent]>[backcolor=transparent]OK[backcolor=transparent]<[backcolor=transparent]/Message><RequestId>E8534574-7381-4810-8F70-65B37BBA8970</[backcolor=transparent]RequestId[backcolor=transparent]><[backcolor=transparent]BizId[backcolor=transparent]>[backcolor=transparent]108374502347[backcolor=transparent]^[backcolor=transparent]1111325525761[backcolor=transparent]<[backcolor=transparent]/BizId><Code>OK</[backcolor=transparent]Code[backcolor=transparent]></[backcolor=transparent]SendSmsResponse[backcolor=transparent]>
2.2 短信Rest请求参数
如HTTP示例包中,请求的参数可以分两大块:系统参数 和 业务参数
系统参数
系统参数为POP协议的基本参数,有
业务参数
[tr=rgb(239, 251, 255)][td]TemplateParam
否 | 具体见API文档描述 |
OutId | 否 | 具体见API文档描述 |