• 欢迎大家分享资料!前往留言板评论即可!

使用物联网卡发送短信

合宙 模组资料网 5个月前 (05-15) 84次浏览 已收录 0个评论 扫描二维码
                    <p style="outline: 0px; padding: 0px; margin-bottom: 16px; font-size: 16px; color: rgb(79, 79, 79); line-height: 26px; text-align: justify; word-break: break-all; font-family: -apple-system, "SF UI Text", Arial, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "WenQuanYi Micro Hei", sans-serif; font-variant-ligatures: common-ligatures;">从2015年9月1日起 ,购买电话卡需要实名制,也就是说需要本人使用身份证才能购买。但是随着物联网的迅速发展,需要联网的终端逐渐增多。在此环境下,诞生了一种不能电话,不能短信,不需要实名制,只能上网的物联网卡。但是在某些场合,需要用到短信功能。本教程使用合宙的API发送短信,一条短信只需要4分钱。</p><p style="outline: 0px; padding: 0px; margin-bottom: 16px; font-size: 16px; color: rgb(79, 79, 79); line-height: 26px; text-align: justify; word-break: break-all; font-family: -apple-system, "SF UI Text", Arial, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "WenQuanYi Micro Hei", sans-serif; font-variant-ligatures: common-ligatures;">1、购买短信</p><p style="outline: 0px; padding: 0px; margin-bottom: 16px; font-size: 16px; color: rgb(79, 79, 79); line-height: 26px; text-align: justify; word-break: break-all; font-family: -apple-system, "SF UI Text", Arial, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "WenQuanYi Micro Hei", sans-serif; font-variant-ligatures: common-ligatures;">注册<a href="http://sms.openluat.com/" rel="nofollow noopener" target="_blank" style="outline: 0px; color: rgb(103, 149, 181); cursor: pointer; word-break: break-all;">短信中心</a>账号,并登陆。</p><p style="outline: 0px; padding: 0px; margin-bottom: 16px; font-size: 16px; color: rgb(79, 79, 79); line-height: 26px; text-align: justify; word-break: break-all; font-family: -apple-system, "SF UI Text", Arial, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "WenQuanYi Micro Hei", sans-serif; font-variant-ligatures: common-ligatures;">进入账户管理->充值, 选择您要购买短信的规格,付款</p><p style="outline: 0px; padding: 0px; margin-bottom: 16px; font-size: 16px; color: rgb(79, 79, 79); line-height: 26px; text-align: justify; word-break: break-all; font-family: -apple-system, "SF UI Text", Arial, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "WenQuanYi Micro Hei", sans-serif; font-variant-ligatures: common-ligatures;"><img src="https://img-blog.csdn.net/20180802083522242?watermark/2/text/aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L2E5MDkyMDQwMTM=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70" alt="这里写图片描述" title="" style="outline: 0px; border-style: none; margin: 24px 0px; max-width: 100%; word-break: break-all; cursor: zoom-in;"> <br style="outline: 0px; word-break: break-all;">2、新建签名</p><p style="outline: 0px; padding: 0px; margin-bottom: 16px; font-size: 16px; color: rgb(79, 79, 79); line-height: 26px; text-align: justify; word-break: break-all; font-family: -apple-system, "SF UI Text", Arial, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "WenQuanYi Micro Hei", sans-serif; font-variant-ligatures: common-ligatures;">进入签名管理->签名管理->新建, 签名创建完成之后,在签名管理页面查看签名状态,<span style="outline: 0px; font-weight: 700; word-break: break-all;">签名审核通过之后就可以用来发送短信。</span></p><p style="outline: 0px; padding: 0px; margin-bottom: 16px; font-size: 16px; color: rgb(79, 79, 79); line-height: 26px; text-align: justify; word-break: break-all; font-family: -apple-system, "SF UI Text", Arial, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "WenQuanYi Micro Hei", sans-serif; font-variant-ligatures: common-ligatures;"><img src="http://oldask.openluat.com/image/show/attachments-2018-09-qJbOnsVi5b9c7706ce421.png" title="使用物联网卡发送短信" class="img-responsive" style="color: rgb(0, 0, 0); font-family: "Helvetica Neue", Helvetica, Arial, "PingFang SC", "Hiragino Sans GB", "WenQuanYi Micro Hei", "Microsoft Yahei", sans-serif; font-size: 14px; font-variant-ligatures: normal; text-align: start; width: 565.6px;"></p><div><br></div><ul style="outline: 0px; margin-right: 0px; margin-bottom: 24px; margin-left: 0px; word-break: break-all; color: rgba(0, 0, 0, 0.75); font-family: -apple-system, "SF UI Text", Arial, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "WenQuanYi Micro Hei", sans-serif; font-variant-ligatures: common-ligatures;"><li style="outline: 0px; padding: 0px; margin: 8px 0px 0px 32px; list-style-type: disc; word-break: break-all;"><p style="outline: 0px; padding: 0px; margin-bottom: 16px; font-size: 16px; color: rgb(79, 79, 79); line-height: 26px; text-align: justify; word-break: break-all;">发送短信之前,客户首先需要在公司平台对签名进行备案,备案时需要提供签名的文本。</p></li><li style="outline: 0px; padding: 0px; margin: 8px 0px 0px 32px; list-style-type: disc; word-break: break-all;"><p style="outline: 0px; padding: 0px; margin-bottom: 16px; font-size: 16px; color: rgb(79, 79, 79); line-height: 26px; text-align: justify; word-break: break-all;">提交的短信签名 2-10 个字符; 建议全用中文。</p></li><li style="outline: 0px; padding: 0px; margin: 8px 0px 0px 32px; list-style-type: disc; word-break: break-all;"><p style="outline: 0px; padding: 0px; margin-bottom: 16px; font-size: 16px; color: rgb(79, 79, 79); line-height: 26px; text-align: justify; word-break: break-all;">其中“梅云飞”就是签名,<span style="outline: 0px; font-weight: 700; word-break: break-all;">如果没有签名就不能发送短信 </span>。</p><p style="outline: 0px; padding: 0px; margin-bottom: 16px; font-size: 16px; color: rgb(79, 79, 79); line-height: 26px; text-align: justify; word-break: break-all;"><img src="http://oldask.openluat.com/image/show/attachments-2018-09-RfsCjBO15b9c7777c63a7.png" class="img-responsive" style="color: rgb(0, 0, 0); font-family: "Helvetica Neue", Helvetica, Arial, "PingFang SC", "Hiragino Sans GB", "WenQuanYi Micro Hei", "Microsoft Yahei", sans-serif; font-size: 14px; font-variant-ligatures: normal; text-align: start; width: 373.5px;"></p></li><li style="outline: 0px; padding: 0px; margin: 8px 0px 0px 32px; list-style-type: disc; word-break: break-all;"><div>审核时间为工作日的9点至17点</div></li></ul><p style="outline: 0px; padding: 0px; margin-bottom: 16px; font-size: 16px; color: rgb(79, 79, 79); line-height: 26px; text-align: justify; word-break: break-all; font-family: -apple-system, "SF UI Text", Arial, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "WenQuanYi Micro Hei", sans-serif; font-variant-ligatures: common-ligatures;">3、新建模版</p><p style="outline: 0px; padding: 0px; margin-bottom: 16px; font-size: 16px; color: rgb(79, 79, 79); line-height: 26px; text-align: justify; word-break: break-all; font-family: -apple-system, "SF UI Text", Arial, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "WenQuanYi Micro Hei", sans-serif; font-variant-ligatures: common-ligatures;">进入签名管理->模版管理->新建, 模版创建成功之后,在模版管理页面查看模版状态,模版审核通过之后就可以用来发送短信, <span style="outline: 0px; font-weight: 700; word-break: break-all;">如果没有通过的模版就不能发送短信</span></p><p style="outline: 0px; padding: 0px; margin-bottom: 16px; font-size: 16px; color: rgb(79, 79, 79); line-height: 26px; text-align: justify; word-break: break-all; font-family: -apple-system, "SF UI Text", Arial, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "WenQuanYi Micro Hei", sans-serif; font-variant-ligatures: common-ligatures;"><img src="http://oldask.openluat.com/image/show/attachments-2018-09-jCl2JiFO5b9c77e171ea4.png" title="使用物联网卡发送短信" class="img-responsive" style="color: rgb(0, 0, 0); font-family: "Helvetica Neue", Helvetica, Arial, "PingFang SC", "Hiragino Sans GB", "WenQuanYi Micro Hei", "Microsoft Yahei", sans-serif; font-size: 14px; font-variant-ligatures: normal; text-align: start; width: 565.6px;"></p><div><br></div><p style="outline: 0px; padding: 0px; margin-bottom: 16px; font-size: 16px; color: rgb(79, 79, 79); line-height: 26px; text-align: justify; word-break: break-all; font-family: -apple-system, "SF UI Text", Arial, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "WenQuanYi Micro Hei", sans-serif; font-variant-ligatures: common-ligatures;">注:</p><ul style="outline: 0px; margin-right: 0px; margin-bottom: 24px; margin-left: 0px; word-break: break-all; color: rgba(0, 0, 0, 0.75); font-family: -apple-system, "SF UI Text", Arial, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "WenQuanYi Micro Hei", sans-serif; font-variant-ligatures: common-ligatures;"><li style="outline: 0px; padding: 0px; margin: 8px 0px 0px 32px; list-style-type: disc; word-break: break-all;"><p style="outline: 0px; padding: 0px; margin-bottom: 16px; font-size: 16px; color: rgb(79, 79, 79); line-height: 26px; text-align: justify; word-break: break-all;">发送新短信内容之前,客户首先需要在我公司平台对模板进行备案,备案时需要提供模板的文本。后面发送已通过模版的内容就不用申请模版了。</p><p style="outline: 0px; padding: 0px; margin-bottom: 16px; font-size: 16px; color: rgb(79, 79, 79); line-height: 26px; text-align: justify; word-break: break-all;">提交报备模板规范: <br style="outline: 0px; word-break: break-all;">提交短信模板的内容规则,例 <br style="outline: 0px; word-break: break-all;">例 1:您的验证码是????,请在 5 分钟内使用。 <br style="outline: 0px; word-break: break-all;">例 2:%先生,欢迎您光临%店铺,祝您购物愉快。 <br style="outline: 0px; word-break: break-all;">? 和 % 表示通配符,?匹配 1 个字符,%匹配 N 个字符。 <br style="outline: 0px; word-break: break-all;">说明: <br style="outline: 0px; word-break: break-all;">其中N匹配0到多个字符 <br style="outline: 0px; word-break: break-all;">发送提交短信的内容: <br style="outline: 0px; word-break: break-all;">通过短信发送页面发送短信,短信的内容规则为: <br style="outline: 0px; word-break: break-all;">例:您的验证码是 1234,请在 5 分钟内使用。</p></li></ul><p style="outline: 0px; padding: 0px; margin-bottom: 16px; font-size: 16px; color: rgb(79, 79, 79); line-height: 26px; text-align: justify; word-break: break-all; font-family: -apple-system, "SF UI Text", Arial, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "WenQuanYi Micro Hei", sans-serif; font-variant-ligatures: common-ligatures;">4、创建应用</p><p style="outline: 0px; padding: 0px; margin-bottom: 16px; font-size: 16px; color: rgb(79, 79, 79); line-height: 26px; text-align: justify; word-break: break-all; font-family: -apple-system, "SF UI Text", Arial, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "WenQuanYi Micro Hei", sans-serif; font-variant-ligatures: common-ligatures;">进入应用管理->创建应用,填写您要创建的应用名称,应用描述,然后创建。</p><p style="outline: 0px; padding: 0px; margin-bottom: 16px; font-size: 16px; color: rgb(79, 79, 79); line-height: 26px; text-align: justify; word-break: break-all; font-family: -apple-system, "SF UI Text", Arial, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "WenQuanYi Micro Hei", sans-serif; font-variant-ligatures: common-ligatures;"><img src="http://oldask.openluat.com/image/show/attachments-2018-09-VFMM0j7z5b9c77fa942c4.png" class="img-responsive" style="color: rgb(0, 0, 0); font-family: "Helvetica Neue", Helvetica, Arial, "PingFang SC", "Hiragino Sans GB", "WenQuanYi Micro Hei", "Microsoft Yahei", sans-serif; font-size: 14px; font-variant-ligatures: normal; text-align: start; width: 50%;"></p><div><br></div><p style="outline: 0px; padding: 0px; margin-bottom: 16px; font-size: 16px; color: rgb(79, 79, 79); line-height: 26px; text-align: justify; word-break: break-all; font-family: -apple-system, "SF UI Text", Arial, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "WenQuanYi Micro Hei", sans-serif; font-variant-ligatures: common-ligatures;">创建应用成功后在应用管理->应用列表里面查看自己的应用,应用的appkey,appsecret用于下面API接口的调用</p><p style="outline: 0px; padding: 0px; margin-bottom: 16px; font-size: 16px; color: rgb(79, 79, 79); line-height: 26px; text-align: justify; word-break: break-all; font-family: -apple-system, "SF UI Text", Arial, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "WenQuanYi Micro Hei", sans-serif; font-variant-ligatures: common-ligatures;">至此,可以通过短信平台发送短信了。</p><p style="outline: 0px; padding: 0px; margin-bottom: 16px; font-size: 16px; color: rgb(79, 79, 79); line-height: 26px; text-align: justify; word-break: break-all; font-family: -apple-system, "SF UI Text", Arial, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "WenQuanYi Micro Hei", sans-serif; font-variant-ligatures: common-ligatures;"><img src="http://oldask.openluat.com/image/show/attachments-2018-09-u1oHrjPW5b9c781a28314.png" class="img-responsive" style="color: rgb(0, 0, 0); font-family: "Helvetica Neue", Helvetica, Arial, "PingFang SC", "Hiragino Sans GB", "WenQuanYi Micro Hei", "Microsoft Yahei", sans-serif; font-size: 14px; font-variant-ligatures: normal; text-align: start; width: 524px;"></p><div><br></div><p style="outline: 0px; padding: 0px; margin-bottom: 16px; font-size: 16px; color: rgb(79, 79, 79); line-height: 26px; text-align: justify; word-break: break-all; font-family: -apple-system, "SF UI Text", Arial, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "WenQuanYi Micro Hei", sans-serif; font-variant-ligatures: common-ligatures;"><br></p><p style="outline: 0px; padding: 0px; margin-bottom: 16px; font-size: 16px; color: rgb(79, 79, 79); line-height: 26px; text-align: justify; word-break: break-all; font-family: -apple-system, "SF UI Text", Arial, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "WenQuanYi Micro Hei", sans-serif; font-variant-ligatures: common-ligatures;">可以在发送记录中查看发送状态 <br style="outline: 0px; word-break: break-all;"><img src="http://oldask.openluat.com/image/show/attachments-2018-09-MS3cPRaR5b9c783370901.png" class="img-responsive" style="color: rgb(0, 0, 0); font-family: "Helvetica Neue", Helvetica, Arial, "PingFang SC", "Hiragino Sans GB", "WenQuanYi Micro Hei", "Microsoft Yahei", sans-serif; font-size: 14px; font-variant-ligatures: normal; text-align: start; width: 311px;"></p><div><br></div><p style="outline: 0px; padding: 0px; margin-bottom: 16px; font-size: 16px; color: rgb(79, 79, 79); line-height: 26px; text-align: justify; word-break: break-all; font-family: -apple-system, "SF UI Text", Arial, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "WenQuanYi Micro Hei", sans-serif; font-variant-ligatures: common-ligatures;">除了使用短信平台发送短信,还可以使用API发送短信。</p><h1 id="短信api" style="outline: 0px; padding: 0px; margin-top: 8px; margin-bottom: 16px; font-size: 28px; color: rgb(79, 79, 79); font-weight: 700; line-height: 36px; word-break: break-all; font-family: -apple-system, "SF UI Text", Arial, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "WenQuanYi Micro Hei", sans-serif; font-variant-ligatures: common-ligatures;">短信API</h1><p style="outline: 0px; padding: 0px; margin-bottom: 16px; font-size: 16px; color: rgb(79, 79, 79); line-height: 26px; text-align: justify; word-break: break-all; font-family: -apple-system, "SF UI Text", Arial, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "WenQuanYi Micro Hei", sans-serif; font-variant-ligatures: common-ligatures;"><span style="outline: 0px; font-weight: 700; word-break: break-all;">请求URL :</span></p><ul style="outline: 0px; margin-right: 0px; margin-bottom: 24px; margin-left: 0px; word-break: break-all; color: rgba(0, 0, 0, 0.75); font-family: -apple-system, "SF UI Text", Arial, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "WenQuanYi Micro Hei", sans-serif; font-variant-ligatures: common-ligatures;"><li style="outline: 0px; padding: 0px; margin: 8px 0px 0px 32px; list-style-type: disc; word-break: break-all;"><p style="outline: 0px; padding: 0px; margin-bottom: 16px; font-size: 16px; color: rgb(79, 79, 79); line-height: 26px; text-align: justify; word-break: break-all;"><code>api.openluat.com/sms/send</code></p><p style="outline: 0px; padding: 0px; margin-bottom: 16px; font-size: 16px; color: rgb(79, 79, 79); line-height: 26px; text-align: justify; word-break: break-all;">请求方式:POST</p></li></ul><p style="outline: 0px; padding: 0px; margin-bottom: 16px; font-size: 16px; color: rgb(79, 79, 79); line-height: 26px; text-align: justify; word-break: break-all; font-family: -apple-system, "SF UI Text", Arial, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "WenQuanYi Micro Hei", sans-serif; font-variant-ligatures: common-ligatures;"><span style="outline: 0px; font-weight: 700; word-break: break-all;">认证:</span></p><ul style="outline: 0px; margin-right: 0px; margin-bottom: 24px; margin-left: 0px; word-break: break-all; color: rgba(0, 0, 0, 0.75); font-family: -apple-system, "SF UI Text", Arial, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "WenQuanYi Micro Hei", sans-serif; font-variant-ligatures: common-ligatures;"><li style="outline: 0px; padding: 0px; margin: 8px 0px 0px 32px; list-style-type: disc; word-break: break-all;">在headers中增加Basic auth的认证,填入(appkey, appsecret)</li><li style="outline: 0px; padding: 0px; margin: 8px 0px 0px 32px; list-style-type: disc; word-break: break-all;">认证方式为HTTP Basic Authorization,认证信息为appkey:appsecret,详细调用请参考各个语言的HTTP Basic Authorization</li></ul><p style="outline: 0px; padding: 0px; margin-bottom: 16px; font-size: 16px; color: rgb(79, 79, 79); line-height: 26px; text-align: justify; word-break: break-all; font-family: -apple-system, "SF UI Text", Arial, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "WenQuanYi Micro Hei", sans-serif; font-variant-ligatures: common-ligatures;">以下补充关于Basic Authorization相关知识:</p><p style="outline: 0px; padding: 0px; margin-bottom: 16px; font-size: 16px; color: rgb(79, 79, 79); line-height: 26px; text-align: justify; word-break: break-all; font-family: -apple-system, "SF UI Text", Arial, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "WenQuanYi Micro Hei", sans-serif; font-variant-ligatures: common-ligatures;">在HTTP中,<span style="outline: 0px; font-weight: 700; word-break: break-all;">基本认证</span>(Basic access authentication)是一种用来允许网页浏览器或其他客户端程序在请求时提供用户名和口令形式的身份凭证的一种登录验证方式。</p><p style="outline: 0px; padding: 0px; margin-bottom: 16px; font-size: 16px; color: rgb(79, 79, 79); line-height: 26px; text-align: justify; word-break: break-all; font-family: -apple-system, "SF UI Text", Arial, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "WenQuanYi Micro Hei", sans-serif; font-variant-ligatures: common-ligatures;">在发送之前是以用户名追加一个冒号然后串接上口令,并将得出的结果字符串再用Base64算法编码。例如,提供的用户名是<code>Aladdin</code>、口令是<code>open sesame</code>,则拼接后的结果就是<code>Aladdin:open sesame</code>,然后再将其用Base64编码,得到<code>QWxhZGRpbjpvcGVuIHNlc2FtZQ==</code>。最终将Base64编码的字符串发送出去,由接收者解码得到一个由冒号分隔的用户名和口令的字符串。(摘自维基百科)</p><p style="outline: 0px; padding: 0px; margin-bottom: 16px; font-size: 16px; color: rgb(79, 79, 79); line-height: 26px; text-align: justify; word-break: break-all; font-family: -apple-system, "SF UI Text", Arial, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "WenQuanYi Micro Hei", sans-serif; font-variant-ligatures: common-ligatures;">服务器将Authorization header中的用户名密码取出,进行验证, 如果验证通过,将根据请求,发送资源给客户端</p><p style="outline: 0px; padding: 0px; margin-bottom: 16px; font-size: 16px; color: rgb(79, 79, 79); line-height: 26px; text-align: justify; word-break: break-all; font-family: -apple-system, "SF UI Text", Arial, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "WenQuanYi Micro Hei", sans-serif; font-variant-ligatures: common-ligatures;"><img src="http://oldask.openluat.com/image/show/attachments-2018-09-Jmo6JnTo5b9c784a579d7.png" class="img-responsive" style="color: rgb(0, 0, 0); font-family: "Helvetica Neue", Helvetica, Arial, "PingFang SC", "Hiragino Sans GB", "WenQuanYi Micro Hei", "Microsoft Yahei", sans-serif; font-size: 14px; font-variant-ligatures: normal; text-align: start; width: 611px;"></p><div><br></div><p style="outline: 0px; padding: 0px; margin-bottom: 16px; font-size: 16px; color: rgb(79, 79, 79); line-height: 26px; text-align: justify; word-break: break-all; font-family: -apple-system, "SF UI Text", Arial, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "WenQuanYi Micro Hei", sans-serif; font-variant-ligatures: common-ligatures;"><a href="https://www.cnblogs.com/chenrong/articles/5818498.html" rel="nofollow noopener" target="_blank" style="outline: 0px; color: rgb(103, 149, 181); cursor: pointer; word-break: break-all;">http authorization 基本认证</a></p><p style="outline: 0px; padding: 0px; margin-bottom: 16px; font-size: 16px; color: rgb(79, 79, 79); line-height: 26px; text-align: justify; word-break: break-all; font-family: -apple-system, "SF UI Text", Arial, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "WenQuanYi Micro Hei", sans-serif; font-variant-ligatures: common-ligatures;"><span style="outline: 0px; font-weight: 700; word-break: break-all;">参数:</span></p><table style="outline: 0px; background-color: rgb(255, 255, 255); width: 852px; text-align: center; margin-bottom: 24px; word-break: break-all; color: rgba(0, 0, 0, 0.75); font-family: -apple-system, "SF UI Text", Arial, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "WenQuanYi Micro Hei", sans-serif; font-variant-ligatures: common-ligatures;"><thead style="outline: 0px; word-break: break-all;"><tr style="outline: 0px; border-width: 1px 0px 0px; border-right-style: initial; border-bottom-style: initial; border-left-style: initial; border-right-color: initial; border-bottom-color: initial; border-left-color: initial; border-image: initial; border-top-style: solid; border-top-color: rgb(221, 221, 221); word-break: break-all;"><th align="left" style="outline: 0px; padding: 8px; margin: 0px; border: 1px solid rgb(221, 221, 221); word-break: normal; color: rgb(79, 79, 79); line-height: 22px; word-wrap: break-word; vertical-align: middle; background-color: rgb(239, 243, 245);">参数名</th><th style="outline: 0px; padding: 8px; margin: 0px; border: 1px solid rgb(221, 221, 221); word-break: normal; color: rgb(79, 79, 79); line-height: 22px; word-wrap: break-word; vertical-align: middle; background-color: rgb(239, 243, 245);">必选</th><th style="outline: 0px; padding: 8px; margin: 0px; border: 1px solid rgb(221, 221, 221); word-break: normal; color: rgb(79, 79, 79); line-height: 22px; word-wrap: break-word; vertical-align: middle; background-color: rgb(239, 243, 245);">类型</th><th style="outline: 0px; padding: 8px; margin: 0px; border: 1px solid rgb(221, 221, 221); word-break: normal; color: rgb(79, 79, 79); line-height: 22px; word-wrap: break-word; vertical-align: middle; background-color: rgb(239, 243, 245);">说明</th></tr></thead><tbody style="outline: 0px; border: 0px; word-break: break-all;"><tr style="outline: 0px; border-width: 1px 0px 0px; border-right-style: initial; border-bottom-style: initial; border-left-style: initial; border-right-color: initial; border-bottom-color: initial; border-left-color: initial; border-image: initial; border-top-style: solid; border-top-color: rgb(221, 221, 221); word-break: break-all;"><td align="left" style="outline: 0px; padding: 8px; margin: 0px; border: 1px solid rgb(221, 221, 221); word-break: normal; color: rgb(79, 79, 79); line-height: 22px; word-wrap: break-word; vertical-align: middle;">content</td><td style="outline: 0px; padding: 8px; margin: 0px; border: 1px solid rgb(221, 221, 221); word-break: normal; color: rgb(79, 79, 79); line-height: 22px; word-wrap: break-word; vertical-align: middle;">是</td><td style="outline: 0px; padding: 8px; margin: 0px; border: 1px solid rgb(221, 221, 221); word-break: normal; color: rgb(79, 79, 79); line-height: 22px; word-wrap: break-word; vertical-align: middle;">string</td><td style="outline: 0px; padding: 8px; margin: 0px; border: 1px solid rgb(221, 221, 221); word-break: normal; color: rgb(79, 79, 79); line-height: 22px; word-wrap: break-word; vertical-align: middle;">短信内容</td></tr><tr style="outline: 0px; border-width: 1px 0px 0px; border-right-style: initial; border-bottom-style: initial; border-left-style: initial; border-right-color: initial; border-bottom-color: initial; border-left-color: initial; border-image: initial; border-top-style: solid; border-top-color: rgb(221, 221, 221); background-color: rgb(247, 247, 247); word-break: break-all;"><td align="left" style="outline: 0px; padding: 8px; margin: 0px; border: 1px solid rgb(221, 221, 221); word-break: normal; color: rgb(79, 79, 79); line-height: 22px; word-wrap: break-word; vertical-align: middle;">phone</td><td style="outline: 0px; padding: 8px; margin: 0px; border: 1px solid rgb(221, 221, 221); word-break: normal; color: rgb(79, 79, 79); line-height: 22px; word-wrap: break-word; vertical-align: middle;">是</td><td style="outline: 0px; padding: 8px; margin: 0px; border: 1px solid rgb(221, 221, 221); word-break: normal; color: rgb(79, 79, 79); line-height: 22px; word-wrap: break-word; vertical-align: middle;">string</td><td style="outline: 0px; padding: 8px; margin: 0px; border: 1px solid rgb(221, 221, 221); word-break: normal; color: rgb(79, 79, 79); line-height: 22px; word-wrap: break-word; vertical-align: middle;">被叫号码,多个被叫号码用英文的逗号分隔,最多支持 100 个被叫号码。</td></tr><tr style="outline: 0px; border-width: 1px 0px 0px; border-right-style: initial; border-bottom-style: initial; border-left-style: initial; border-right-color: initial; border-bottom-color: initial; border-left-color: initial; border-image: initial; border-top-style: solid; border-top-color: rgb(221, 221, 221); word-break: break-all;"><td align="left" style="outline: 0px; padding: 8px; margin: 0px; border: 1px solid rgb(221, 221, 221); word-break: normal; color: rgb(79, 79, 79); line-height: 22px; word-wrap: break-word; vertical-align: middle;">sign</td><td style="outline: 0px; padding: 8px; margin: 0px; border: 1px solid rgb(221, 221, 221); word-break: normal; color: rgb(79, 79, 79); line-height: 22px; word-wrap: break-word; vertical-align: middle;">是</td><td style="outline: 0px; padding: 8px; margin: 0px; border: 1px solid rgb(221, 221, 221); word-break: normal; color: rgb(79, 79, 79); line-height: 22px; word-wrap: break-word; vertical-align: middle;">string</td><td style="outline: 0px; padding: 8px; margin: 0px; border: 1px solid rgb(221, 221, 221); word-break: normal; color: rgb(79, 79, 79); line-height: 22px; word-wrap: break-word; vertical-align: middle;">签名</td></tr></tbody></table><p style="outline: 0px; padding: 0px; margin-bottom: 16px; font-size: 16px; color: rgb(79, 79, 79); line-height: 26px; text-align: justify; word-break: break-all; font-family: -apple-system, "SF UI Text", Arial, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "WenQuanYi Micro Hei", sans-serif; font-variant-ligatures: common-ligatures;"><span style="outline: 0px; font-weight: 700; word-break: break-all;">返回示例</span></p><pre class="prettyprint" name="code" style="outline: 0px; padding: 8px 16px 6px 56px; margin-bottom: 24px; font-family: Consolas, Inconsolata, Courier, monospace; font-size: 14px; position: relative; overflow-y: hidden; line-height: 22px; color: rgb(0, 0, 0); background-color: rgb(246, 248, 250); border-width: initial; border-style: none; border-color: initial; font-variant-ligatures: common-ligatures;"><code class="language-lua hljs  has-numbering" style="outline: 0px; font-family: Consolas, Inconsolata, Courier, monospace; font-size: 14px; display: block; padding: 0.5em; color: rgb(0, 0, 0); line-height: 22px; background-color: rgb(246, 248, 250); border-radius: 4px; overflow-x: auto; white-space: pre; word-wrap: normal; text-size-adjust: none; word-break: break-all;"> {
<span class="hljs-string" style="outline: 0px; color: rgb(0, 153, 0); font-size: inherit; word-break: break-all;">"code"</span>: <span class="hljs-number" style="outline: 0px; color: rgb(0, 102, 102); font-size: inherit; word-break: break-all;">0</span>,
<span class="hljs-string" style="outline: 0px; color: rgb(0, 153, 0); font-size: inherit; word-break: break-all;">"msg"</span>: <span class="hljs-string" style="outline: 0px; color: rgb(0, 153, 0); font-size: inherit; word-break: break-all;">''</span>,
<span class="hljs-string" style="outline: 0px; color: rgb(0, 153, 0); font-size: inherit; word-break: break-all;">"msgid"</span>:<span class="hljs-string" style="outline: 0px; color: rgb(0, 153, 0); font-size: inherit; word-break: break-all;">'592FAC0300000D70'</span>

}

  • 1
  • 2
  • 3
  • 4
  • 5

返回参数说明:

参数名 类型 说明
code int 状态码,0:成功;1:失败
msg string 错误提示: code为1时才有
msgid string 消息id:用于匹配回调中的 msgid

下面提供几个实际操作示例

python

<code class="language-python hljs  has-numbering" style="outline: 0px; font-family: Consolas, Inconsolata, Courier, monospace; font-size: 14px; display: block; padding: 0.5em; color: rgb(0, 0, 0); line-height: 22px; background-color: rgb(246, 248, 250); border-radius: 4px; overflow-x: auto; white-space: pre; word-wrap: normal; text-size-adjust: none; word-break: break-all;"><span class="hljs-keyword" style="outline: 0px; color: rgb(0, 0, 136); font-size: inherit; word-break: break-all;">import</span> requests
<span class="hljs-keyword" style="outline: 0px; color: rgb(0, 0, 136); font-size: inherit; word-break: break-all;">from</span> requests.auth <span class="hljs-keyword" style="outline: 0px; color: rgb(0, 0, 136); font-size: inherit; word-break: break-all;">import</span> HTTPBasicAuth
url = <span class="hljs-string" style="outline: 0px; color: rgb(0, 153, 0); font-size: inherit; word-break: break-all;">'https://api.openluat.com/sms/send'</span>
payload = {
    <span class="hljs-string" style="outline: 0px; color: rgb(0, 153, 0); font-size: inherit; word-break: break-all;">'content'</span>: <span class="hljs-string" style="outline: 0px; color: rgb(0, 153, 0); font-size: inherit; word-break: break-all;">'您的验证码是1234,请在5分钟内使用。'</span>,
    <span class="hljs-string" style="outline: 0px; color: rgb(0, 153, 0); font-size: inherit; word-break: break-all;">'phone'</span>: <span class="hljs-string" style="outline: 0px; color: rgb(0, 153, 0); font-size: inherit; word-break: break-all;">'手机号'</span>,
    <span class="hljs-string" style="outline: 0px; color: rgb(0, 153, 0); font-size: inherit; word-break: break-all;">'sign'</span>: <span class="hljs-string" style="outline: 0px; color: rgb(0, 153, 0); font-size: inherit; word-break: break-all;">'签名'</span>,  <span class="hljs-comment" style="outline: 0px; color: rgb(136, 0, 0); font-size: inherit; word-break: break-all;">#sign是在 http://sms.openluat.com/temp 创建的</span>
}
appkey = <span class="hljs-string" style="outline: 0px; color: rgb(0, 153, 0); font-size: inherit; word-break: break-all;">'appkey'</span>
appsecret = <span class="hljs-string" style="outline: 0px; color: rgb(0, 153, 0); font-size: inherit; word-break: break-all;">'appsecret'</span>
<span class="hljs-comment" style="outline: 0px; color: rgb(136, 0, 0); font-size: inherit; word-break: break-all;">#appkey,appsecret是在 http://sms.openluat.com/establish 创建的</span>
<span class="hljs-comment" style="outline: 0px; color: rgb(136, 0, 0); font-size: inherit; word-break: break-all;">#在 http://sms.openluat.com/establog 查看自己的appkey,appsecret。</span>
auth = HTTPBasicAuth(appkey, appsecret)
r = requests.post(url, data=payload, auth=auth)
print(r.json())</code><ul class="pre-numbering" style="outline: 0px; padding-top: 8px; padding-bottom: 8px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-size: inherit; word-break: break-all; position: absolute; width: 48px; background-color: rgb(238, 240, 244); top: 0px; left: 0px; text-align: right;"><li style="outline: 0px; padding: 0px 8px; margin: 0px; font-size: inherit; list-style: none; word-break: break-all; color: rgb(153, 153, 153);">1</li><li style="outline: 0px; padding: 0px 8px; margin: 0px; font-size: inherit; list-style: none; word-break: break-all; color: rgb(153, 153, 153);">2</li><li style="outline: 0px; padding: 0px 8px; margin: 0px; font-size: inherit; list-style: none; word-break: break-all; color: rgb(153, 153, 153);">3</li><li style="outline: 0px; padding: 0px 8px; margin: 0px; font-size: inherit; list-style: none; word-break: break-all; color: rgb(153, 153, 153);">4</li><li style="outline: 0px; padding: 0px 8px; margin: 0px; font-size: inherit; list-style: none; word-break: break-all; color: rgb(153, 153, 153);">5</li><li style="outline: 0px; padding: 0px 8px; margin: 0px; font-size: inherit; list-style: none; word-break: break-all; color: rgb(153, 153, 153);">6</li><li style="outline: 0px; padding: 0px 8px; margin: 0px; font-size: inherit; list-style: none; word-break: break-all; color: rgb(153, 153, 153);">7</li><li style="outline: 0px; padding: 0px 8px; margin: 0px; font-size: inherit; list-style: none; word-break: break-all; color: rgb(153, 153, 153);">8</li><li style="outline: 0px; padding: 0px 8px; margin: 0px; font-size: inherit; list-style: none; word-break: break-all; color: rgb(153, 153, 153);">9</li><li style="outline: 0px; padding: 0px 8px; margin: 0px; font-size: inherit; list-style: none; word-break: break-all; color: rgb(153, 153, 153);">10</li><li style="outline: 0px; padding: 0px 8px; margin: 0px; font-size: inherit; list-style: none; word-break: break-all; color: rgb(153, 153, 153);">11</li><li style="outline: 0px; padding: 0px 8px; margin: 0px; font-size: inherit; list-style: none; word-break: break-all; color: rgb(153, 153, 153);">12</li><li style="outline: 0px; padding: 0px 8px; margin: 0px; font-size: inherit; list-style: none; word-break: break-all; color: rgb(153, 153, 153);">13</li><li style="outline: 0px; padding: 0px 8px; margin: 0px; font-size: inherit; list-style: none; word-break: break-all; color: rgb(153, 153, 153);">14</li><li style="outline: 0px; padding: 0px 8px; margin: 0px; font-size: inherit; list-style: none; word-break: break-all; color: rgb(153, 153, 153);">15</li></ul>

以下示例使用Air202模块,Air202模块可以同时采用Lua语言进行二次开发和AT命令开发。

luat

<code class="language-lua hljs  has-numbering" style="outline: 0px; font-family: Consolas, Inconsolata, Courier, monospace; font-size: 14px; display: block; padding: 0.5em; color: rgb(0, 0, 0); line-height: 22px; background-color: rgb(246, 248, 250); border-radius: 4px; overflow-x: auto; white-space: pre; word-wrap: normal; text-size-adjust: none; word-break: break-all;"><span class="hljs-built_in" style="outline: 0px; color: rgb(79, 79, 79); font-size: inherit; word-break: break-all;">module</span>(...,<span class="hljs-built_in" style="outline: 0px; color: rgb(79, 79, 79); font-size: inherit; word-break: break-all;">package</span>.seeall)

<span class="hljs-built_in" style="outline: 0px; color: rgb(79, 79, 79); font-size: inherit; word-break: break-all;">require</span><span class="hljs-string" style="outline: 0px; color: rgb(0, 153, 0); font-size: inherit; word-break: break-all;">"http"</span>

<span class="hljs-comment" style="outline: 0px; color: rgb(136, 0, 0); font-size: inherit; word-break: break-all;">--HTTP发送后的回调函数</span>
<span class="hljs-keyword" style="outline: 0px; color: rgb(0, 0, 136); font-size: inherit; word-break: break-all;">local</span> <span class="hljs-function" style="outline: 0px; font-size: inherit; word-break: break-all;"><span class="hljs-keyword" style="outline: 0px; color: rgb(0, 0, 136); font-size: inherit; word-break: break-all;">function</span> <span class="hljs-title" style="outline: 0px; color: rgb(0, 153, 0); font-size: inherit; word-break: break-all;">cbFnc</span><span class="hljs-params" style="outline: 0px; color: rgb(79, 79, 79); font-size: inherit; word-break: break-all;">(result,prompt,head,body)</span></span>
    log.info(<span class="hljs-string" style="outline: 0px; color: rgb(0, 153, 0); font-size: inherit; word-break: break-all;">"testHttp.cbFnc"</span>,result,prompt)
    <span class="hljs-keyword" style="outline: 0px; color: rgb(0, 0, 136); font-size: inherit; word-break: break-all;">if</span> result <span class="hljs-keyword" style="outline: 0px; color: rgb(0, 0, 136); font-size: inherit; word-break: break-all;">and</span> head <span class="hljs-keyword" style="outline: 0px; color: rgb(0, 0, 136); font-size: inherit; word-break: break-all;">then</span>
        <span class="hljs-keyword" style="outline: 0px; color: rgb(0, 0, 136); font-size: inherit; word-break: break-all;">for</span> k,v <span class="hljs-keyword" style="outline: 0px; color: rgb(0, 0, 136); font-size: inherit; word-break: break-all;">in</span> <span class="hljs-built_in" style="outline: 0px; color: rgb(79, 79, 79); font-size: inherit; word-break: break-all;">pairs</span>(head) <span class="hljs-keyword" style="outline: 0px; color: rgb(0, 0, 136); font-size: inherit; word-break: break-all;">do</span>
            log.info(<span class="hljs-string" style="outline: 0px; color: rgb(0, 153, 0); font-size: inherit; word-break: break-all;">"testHttp.cbFnc"</span>,k..<span class="hljs-string" style="outline: 0px; color: rgb(0, 153, 0); font-size: inherit; word-break: break-all;">": "</span>..v)
        <span class="hljs-keyword" style="outline: 0px; color: rgb(0, 0, 136); font-size: inherit; word-break: break-all;">end</span>
    <span class="hljs-keyword" style="outline: 0px; color: rgb(0, 0, 136); font-size: inherit; word-break: break-all;">end</span>
    <span class="hljs-keyword" style="outline: 0px; color: rgb(0, 0, 136); font-size: inherit; word-break: break-all;">if</span> result <span class="hljs-keyword" style="outline: 0px; color: rgb(0, 0, 136); font-size: inherit; word-break: break-all;">and</span> body <span class="hljs-keyword" style="outline: 0px; color: rgb(0, 0, 136); font-size: inherit; word-break: break-all;">then</span>
        log.info(<span class="hljs-string" style="outline: 0px; color: rgb(0, 153, 0); font-size: inherit; word-break: break-all;">"testHttp.cbFnc"</span>,<span class="hljs-string" style="outline: 0px; color: rgb(0, 153, 0); font-size: inherit; word-break: break-all;">"bodyLen="</span>..body:len())
    <span class="hljs-keyword" style="outline: 0px; color: rgb(0, 0, 136); font-size: inherit; word-break: break-all;">end</span>
<span class="hljs-keyword" style="outline: 0px; color: rgb(0, 0, 136); font-size: inherit; word-break: break-all;">end</span>


http.request(<span class="hljs-string" style="outline: 0px; color: rgb(0, 153, 0); font-size: inherit; word-break: break-all;">"POST"</span>,<span class="hljs-string" style="outline: 0px; color: rgb(0, 153, 0); font-size: inherit; word-break: break-all;">"appkey:[email protected]/sms/send"</span>,
    <span class="hljs-keyword" style="outline: 0px; color: rgb(0, 0, 136); font-size: inherit; word-break: break-all;">nil</span>,{[<span class="hljs-string" style="outline: 0px; color: rgb(0, 153, 0); font-size: inherit; word-break: break-all;">'Content-Type'</span>]=<span class="hljs-string" style="outline: 0px; color: rgb(0, 153, 0); font-size: inherit; word-break: break-all;">"application/x-www-form-urlencoded"</span>},<span class="hljs-string" style="outline: 0px; color: rgb(0, 153, 0); font-size: inherit; word-break: break-all;">"content=您的验证码为:882474,请尽快确认!&phone=18680841753&sign=测试使用"</span>,<span class="hljs-keyword" style="outline: 0px; color: rgb(0, 0, 136); font-size: inherit; word-break: break-all;">nil</span>,cbFnc)
</code><ul class="pre-numbering" style="outline: 0px; padding-top: 8px; padding-bottom: 8px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-size: inherit; word-break: break-all; position: absolute; width: 48px; background-color: rgb(238, 240, 244); top: 0px; left: 0px; text-align: right;"><li style="outline: 0px; padding: 0px 8px; margin: 0px; font-size: inherit; list-style: none; word-break: break-all; color: rgb(153, 153, 153);">1</li><li style="outline: 0px; padding: 0px 8px; margin: 0px; font-size: inherit; list-style: none; word-break: break-all; color: rgb(153, 153, 153);">2</li><li style="outline: 0px; padding: 0px 8px; margin: 0px; font-size: inherit; list-style: none; word-break: break-all; color: rgb(153, 153, 153);">3</li><li style="outline: 0px; padding: 0px 8px; margin: 0px; font-size: inherit; list-style: none; word-break: break-all; color: rgb(153, 153, 153);">4</li><li style="outline: 0px; padding: 0px 8px; margin: 0px; font-size: inherit; list-style: none; word-break: break-all; color: rgb(153, 153, 153);">5</li><li style="outline: 0px; padding: 0px 8px; margin: 0px; font-size: inherit; list-style: none; word-break: break-all; color: rgb(153, 153, 153);">6</li><li style="outline: 0px; padding: 0px 8px; margin: 0px; font-size: inherit; list-style: none; word-break: break-all; color: rgb(153, 153, 153);">7</li><li style="outline: 0px; padding: 0px 8px; margin: 0px; font-size: inherit; list-style: none; word-break: break-all; color: rgb(153, 153, 153);">8</li><li style="outline: 0px; padding: 0px 8px; margin: 0px; font-size: inherit; list-style: none; word-break: break-all; color: rgb(153, 153, 153);">9</li><li style="outline: 0px; padding: 0px 8px; margin: 0px; font-size: inherit; list-style: none; word-break: break-all; color: rgb(153, 153, 153);">10</li><li style="outline: 0px; padding: 0px 8px; margin: 0px; font-size: inherit; list-style: none; word-break: break-all; color: rgb(153, 153, 153);">11</li><li style="outline: 0px; padding: 0px 8px; margin: 0px; font-size: inherit; list-style: none; word-break: break-all; color: rgb(153, 153, 153);">12</li><li style="outline: 0px; padding: 0px 8px; margin: 0px; font-size: inherit; list-style: none; word-break: break-all; color: rgb(153, 153, 153);">13</li><li style="outline: 0px; padding: 0px 8px; margin: 0px; font-size: inherit; list-style: none; word-break: break-all; color: rgb(153, 153, 153);">14</li><li style="outline: 0px; padding: 0px 8px; margin: 0px; font-size: inherit; list-style: none; word-break: break-all; color: rgb(153, 153, 153);">15</li><li style="outline: 0px; padding: 0px 8px; margin: 0px; font-size: inherit; list-style: none; word-break: break-all; color: rgb(153, 153, 153);">16</li><li style="outline: 0px; padding: 0px 8px; margin: 0px; font-size: inherit; list-style: none; word-break: break-all; color: rgb(153, 153, 153);">17</li><li style="outline: 0px; padding: 0px 8px; margin: 0px; font-size: inherit; list-style: none; word-break: break-all; color: rgb(153, 153, 153);">18</li><li style="outline: 0px; padding: 0px 8px; margin: 0px; font-size: inherit; list-style: none; word-break: break-all; color: rgb(153, 153, 153);">19</li><li style="outline: 0px; padding: 0px 8px; margin: 0px; font-size: inherit; list-style: none; word-break: break-all; color: rgb(153, 153, 153);">20</li><li style="outline: 0px; padding: 0px 8px; margin: 0px; font-size: inherit; list-style: none; word-break: break-all; color: rgb(153, 153, 153);">21</li></ul>

从trace输出看到已经发送成功

使用物联网卡发送短信

AT

使用AT命令也可以通过调用API发送短信

<code class="language-shell hljs perl has-numbering" style="outline: 0px; font-family: Consolas, Inconsolata, Courier, monospace; font-size: 14px; display: block; padding: 0.5em; color: rgb(0, 0, 0); line-height: 22px; background-color: rgb(246, 248, 250); border-radius: 4px; overflow-x: auto; white-space: pre; word-wrap: normal; text-size-adjust: none; word-break: break-all;">->  AT+SAPBR=<span class="hljs-number" style="outline: 0px; color: rgb(0, 102, 102); font-size: inherit; word-break: break-all;">3</span>,<span class="hljs-number" style="outline: 0px; color: rgb(0, 102, 102); font-size: inherit; word-break: break-all;">1</span>,<span class="hljs-string" style="outline: 0px; color: rgb(0, 153, 0); font-size: inherit; word-break: break-all;">"CONTYPE"</span>,<span class="hljs-string" style="outline: 0px; color: rgb(0, 153, 0); font-size: inherit; word-break: break-all;">"GPRS"</span> <span class="hljs-comment" style="outline: 0px; color: rgb(136, 0, 0); font-size: inherit; word-break: break-all;">#设置HTTP功能的承载类型SAPBR是为了激活PDP上下文,激活PDP上下位是为了使用UDP协议,从而可以解析域名。</span>
<-  OK
->  AT+SAPBR=<span class="hljs-number" style="outline: 0px; color: rgb(0, 102, 102); font-size: inherit; word-break: break-all;">3</span>,<span class="hljs-number" style="outline: 0px; color: rgb(0, 102, 102); font-size: inherit; word-break: break-all;">1</span>,<span class="hljs-string" style="outline: 0px; color: rgb(0, 153, 0); font-size: inherit; word-break: break-all;">"APN"</span>,<span class="hljs-string" style="outline: 0px; color: rgb(0, 153, 0); font-size: inherit; word-break: break-all;">"CMNET"</span>  <span class="hljs-comment" style="outline: 0px; color: rgb(136, 0, 0); font-size: inherit; word-break: break-all;">#设置HTTP功能的APN</span>
<-  OK
->  AT+SAPBR=<span class="hljs-number" style="outline: 0px; color: rgb(0, 102, 102); font-size: inherit; word-break: break-all;">5</span>,<span class="hljs-number" style="outline: 0px; color: rgb(0, 102, 102); font-size: inherit; word-break: break-all;">1</span>  <span class="hljs-comment" style="outline: 0px; color: rgb(136, 0, 0); font-size: inherit; word-break: break-all;">#保存cid=1的承载的相关参数(CONTYPE,APN)到NV,这样关机不消失,并且开机后自动恢复为保存的取值。</span>
<-  OK
->  AT+SAPBR=<span class="hljs-number" style="outline: 0px; color: rgb(0, 102, 102); font-size: inherit; word-break: break-all;">1</span>,<span class="hljs-number" style="outline: 0px; color: rgb(0, 102, 102); font-size: inherit; word-break: break-all;">1</span>  <span class="hljs-comment" style="outline: 0px; color: rgb(136, 0, 0); font-size: inherit; word-break: break-all;">#激活该承载的GPRSPDP上下文</span>
<-  OK
->  AT+SAPBR=<span class="hljs-number" style="outline: 0px; color: rgb(0, 102, 102); font-size: inherit; word-break: break-all;">2</span>,<span class="hljs-number" style="outline: 0px; color: rgb(0, 102, 102); font-size: inherit; word-break: break-all;">1</span>  <span class="hljs-comment" style="outline: 0px; color: rgb(136, 0, 0); font-size: inherit; word-break: break-all;">#查询下承载的状态</span>
<-  OK
<-  +SAPBR: <span class="hljs-number" style="outline: 0px; color: rgb(0, 102, 102); font-size: inherit; word-break: break-all;">1</span>,<span class="hljs-number" style="outline: 0px; color: rgb(0, 102, 102); font-size: inherit; word-break: break-all;">1</span>,<span class="hljs-string" style="outline: 0px; color: rgb(0, 153, 0); font-size: inherit; word-break: break-all;">"10.153.61.216"</span> <span class="hljs-comment" style="outline: 0px; color: rgb(136, 0, 0); font-size: inherit; word-break: break-all;">#第一个参数1表示cid,第二个参数1表示已经连接,第三个参数表示模块获取的IP地址</span>
->  AT+HTTPINIT  <span class="hljs-comment" style="outline: 0px; color: rgb(136, 0, 0); font-size: inherit; word-break: break-all;">#HTTP协议栈初始化</span>
<-  OK
->  AT+HTTPPARA=<span class="hljs-string" style="outline: 0px; color: rgb(0, 153, 0); font-size: inherit; word-break: break-all;">"CID"</span>,<span class="hljs-number" style="outline: 0px; color: rgb(0, 102, 102); font-size: inherit; word-break: break-all;">1</span> <span class="hljs-comment" style="outline: 0px; color: rgb(136, 0, 0); font-size: inherit; word-break: break-all;">#设置HTTP会话参数:CID</span>
<-  OK
->  AT+HTTPPARA=<span class="hljs-string" style="outline: 0px; color: rgb(0, 153, 0); font-size: inherit; word-break: break-all;">"URL"</span>,<span class="hljs-string" style="outline: 0px; color: rgb(0, 153, 0); font-size: inherit; word-break: break-all;">"api.openluat.com/sms/send"</span> <span class="hljs-comment" style="outline: 0px; color: rgb(136, 0, 0); font-size: inherit; word-break: break-all;">#设置HTTP会话参数:URL</span>
<-  OK
->  AT+HTTPPARA=<span class="hljs-string" style="outline: 0px; color: rgb(0, 153, 0); font-size: inherit; word-break: break-all;">"USER_DEFINED"</span>,<span class="hljs-string" style="outline: 0px; color: rgb(0, 153, 0); font-size: inherit; word-break: break-all;">"Content-Type: application/x-www-form-urlencoded"</span> <span class="hljs-comment" style="outline: 0px; color: rgb(136, 0, 0); font-size: inherit; word-break: break-all;">#设置自定义参数</span>
<-  OK
->  AT+HTTPPARA=<span class="hljs-string" style="outline: 0px; color: rgb(0, 153, 0); font-size: inherit; word-break: break-all;">"USER_DEFINED"</span>,<span class="hljs-string" style="outline: 0px; color: rgb(0, 153, 0); font-size: inherit; word-break: break-all;">"Authorization: Basic appsecret:appsecret base64编码后的数据"</span>  <span class="hljs-comment" style="outline: 0px; color: rgb(136, 0, 0); font-size: inherit; word-break: break-all;">#设置auth认证</span>
<-  OK

->  AT+HTTPDATA=<span class="hljs-number" style="outline: 0px; color: rgb(0, 102, 102); font-size: inherit; word-break: break-all;">191</span>,<span class="hljs-number" style="outline: 0px; color: rgb(0, 102, 102); font-size: inherit; word-break: break-all;">100000</span> <span class="hljs-comment" style="outline: 0px; color: rgb(136, 0, 0); font-size: inherit; word-break: break-all;">#191为post内容的长度,输入时间要设定的足够大以保证数据输入</span>
DOWNLOAD  <span class="hljs-comment" style="outline: 0px; color: rgb(136, 0, 0); font-size: inherit; word-break: break-all;">#出现download开始输入post内容</span>
content=<span class="hljs-variable" style="outline: 0px; color: rgb(79, 79, 79); font-size: inherit; word-break: break-all;">%E6</span><span class="hljs-variable" style="outline: 0px; color: rgb(79, 79, 79); font-size: inherit; word-break: break-all;">%82</span><span class="hljs-variable" style="outline: 0px; color: rgb(79, 79, 79); font-size: inherit; word-break: break-all;">%A8</span><span class="hljs-variable" style="outline: 0px; color: rgb(79, 79, 79); font-size: inherit; word-break: break-all;">%E7</span><span class="hljs-variable" style="outline: 0px; color: rgb(79, 79, 79); font-size: inherit; word-break: break-all;">%9A</span><span class="hljs-variable" style="outline: 0px; color: rgb(79, 79, 79); font-size: inherit; word-break: break-all;">%84</span><span class="hljs-variable" style="outline: 0px; color: rgb(79, 79, 79); font-size: inherit; word-break: break-all;">%E9</span><span class="hljs-variable" style="outline: 0px; color: rgb(79, 79, 79); font-size: inherit; word-break: break-all;">%AA</span><span class="hljs-variable" style="outline: 0px; color: rgb(79, 79, 79); font-size: inherit; word-break: break-all;">%8C</span><span class="hljs-variable" style="outline: 0px; color: rgb(79, 79, 79); font-size: inherit; word-break: break-all;">%E8</span><span class="hljs-variable" style="outline: 0px; color: rgb(79, 79, 79); font-size: inherit; word-break: break-all;">%AF</span><span class="hljs-variable" style="outline: 0px; color: rgb(79, 79, 79); font-size: inherit; word-break: break-all;">%81</span><span class="hljs-variable" style="outline: 0px; color: rgb(79, 79, 79); font-size: inherit; word-break: break-all;">%E7</span><span class="hljs-variable" style="outline: 0px; color: rgb(79, 79, 79); font-size: inherit; word-break: break-all;">%A0</span><span class="hljs-variable" style="outline: 0px; color: rgb(79, 79, 79); font-size: inherit; word-break: break-all;">%81</span><span class="hljs-variable" style="outline: 0px; color: rgb(79, 79, 79); font-size: inherit; word-break: break-all;">%E4</span><span class="hljs-variable" style="outline: 0px; color: rgb(79, 79, 79); font-size: inherit; word-break: break-all;">%B8</span><span class="hljs-variable" style="outline: 0px; color: rgb(79, 79, 79); font-size: inherit; word-break: break-all;">%BA123456</span><span class="hljs-variable" style="outline: 0px; color: rgb(79, 79, 79); font-size: inherit; word-break: break-all;">%EF</span><span class="hljs-variable" style="outline: 0px; color: rgb(79, 79, 79); font-size: inherit; word-break: break-all;">%BC</span><span class="hljs-variable" style="outline: 0px; color: rgb(79, 79, 79); font-size: inherit; word-break: break-all;">%8C</span><span class="hljs-variable" style="outline: 0px; color: rgb(79, 79, 79); font-size: inherit; word-break: break-all;">%E8</span><span class="hljs-variable" style="outline: 0px; color: rgb(79, 79, 79); font-size: inherit; word-break: break-all;">%AF</span><span class="hljs-variable" style="outline: 0px; color: rgb(79, 79, 79); font-size: inherit; word-break: break-all;">%B7</span><span class="hljs-variable" style="outline: 0px; color: rgb(79, 79, 79); font-size: inherit; word-break: break-all;">%E5</span><span class="hljs-variable" style="outline: 0px; color: rgb(79, 79, 79); font-size: inherit; word-break: break-all;">%B0</span><span class="hljs-variable" style="outline: 0px; color: rgb(79, 79, 79); font-size: inherit; word-break: break-all;">%BD</span><span class="hljs-variable" style="outline: 0px; color: rgb(79, 79, 79); font-size: inherit; word-break: break-all;">%E5</span><span class="hljs-variable" style="outline: 0px; color: rgb(79, 79, 79); font-size: inherit; word-break: break-all;">%BF</span><span class="hljs-variable" style="outline: 0px; color: rgb(79, 79, 79); font-size: inherit; word-break: break-all;">%AB</span><span class="hljs-variable" style="outline: 0px; color: rgb(79, 79, 79); font-size: inherit; word-break: break-all;">%E7</span><span class="hljs-variable" style="outline: 0px; color: rgb(79, 79, 79); font-size: inherit; word-break: break-all;">%A1</span><span class="hljs-variable" style="outline: 0px; color: rgb(79, 79, 79); font-size: inherit; word-break: break-all;">%AE</span><span class="hljs-variable" style="outline: 0px; color: rgb(79, 79, 79); font-size: inherit; word-break: break-all;">%E8</span><span class="hljs-variable" style="outline: 0px; color: rgb(79, 79, 79); font-size: inherit; word-break: break-all;">%AE</span><span class="hljs-variable" style="outline: 0px; color: rgb(79, 79, 79); font-size: inherit; word-break: break-all;">%A4</span><span class="hljs-variable" style="outline: 0px; color: rgb(79, 79, 79); font-size: inherit; word-break: break-all;">%EF</span><span class="hljs-variable" style="outline: 0px; color: rgb(79, 79, 79); font-size: inherit; word-break: break-all;">%BC</span><span class="hljs-variable" style="outline: 0px; color: rgb(79, 79, 79); font-size: inherit; word-break: break-all;">%81</span>&phone=<span class="hljs-number" style="outline: 0px; color: rgb(0, 102, 102); font-size: inherit; word-break: break-all;">18680841753</span>&sign=<span class="hljs-variable" style="outline: 0px; color: rgb(79, 79, 79); font-size: inherit; word-break: break-all;">%E6</span><span class="hljs-variable" style="outline: 0px; color: rgb(79, 79, 79); font-size: inherit; word-break: break-all;">%B5</span><span class="hljs-variable" style="outline: 0px; color: rgb(79, 79, 79); font-size: inherit; word-break: break-all;">%8B</span><span class="hljs-variable" style="outline: 0px; color: rgb(79, 79, 79); font-size: inherit; word-break: break-all;">%E8</span><span class="hljs-variable" style="outline: 0px; color: rgb(79, 79, 79); font-size: inherit; word-break: break-all;">%AF</span><span class="hljs-variable" style="outline: 0px; color: rgb(79, 79, 79); font-size: inherit; word-break: break-all;">%95</span><span class="hljs-variable" style="outline: 0px; color: rgb(79, 79, 79); font-size: inherit; word-break: break-all;">%E4</span><span class="hljs-variable" style="outline: 0px; color: rgb(79, 79, 79); font-size: inherit; word-break: break-all;">%BD</span><span class="hljs-variable" style="outline: 0px; color: rgb(79, 79, 79); font-size: inherit; word-break: break-all;">%BF</span><span class="hljs-variable" style="outline: 0px; color: rgb(79, 79, 79); font-size: inherit; word-break: break-all;">%E7</span><span class="hljs-variable" style="outline: 0px; color: rgb(79, 79, 79); font-size: inherit; word-break: break-all;">%94</span><span class="hljs-variable" style="outline: 0px; color: rgb(79, 79, 79); font-size: inherit; word-break: break-all;">%A8</span>
<-  OK
->  AT+HTTPACTION=<span class="hljs-number" style="outline: 0px; color: rgb(0, 102, 102); font-size: inherit; word-break: break-all;">1</span> <span class="hljs-comment" style="outline: 0px; color: rgb(136, 0, 0); font-size: inherit; word-break: break-all;">#POST开始</span>
<-  OK

+HTTPACTION: <span class="hljs-number" style="outline: 0px; color: rgb(0, 102, 102); font-size: inherit; word-break: break-all;">1</span>,<span class="hljs-number" style="outline: 0px; color: rgb(0, 102, 102); font-size: inherit; word-break: break-all;">200</span>,<span class="hljs-number" style="outline: 0px; color: rgb(0, 102, 102); font-size: inherit; word-break: break-all;">62</span> <span class="hljs-comment" style="outline: 0px; color: rgb(136, 0, 0); font-size: inherit; word-break: break-all;">#POST结束</span>
->  AT+HTTPREAD     <span class="hljs-comment" style="outline: 0px; color: rgb(136, 0, 0); font-size: inherit; word-break: break-all;">#读取返回内容</span>
<-  +HTTPREAD: <span class="hljs-number" style="outline: 0px; color: rgb(0, 102, 102); font-size: inherit; word-break: break-all;">62</span>
{
  <span class="hljs-string" style="outline: 0px; color: rgb(0, 153, 0); font-size: inherit; word-break: break-all;">"code"</span>: <span class="hljs-number" style="outline: 0px; color: rgb(0, 102, 102); font-size: inherit; word-break: break-all;">0</span>, 
  <span class="hljs-string" style="outline: 0px; color: rgb(0, 153, 0); font-size: inherit; word-break: break-all;">"msg"</span>: <span class="hljs-string" style="outline: 0px; color: rgb(0, 153, 0); font-size: inherit; word-break: break-all;">""</span>, 
  <span class="hljs-string" style="outline: 0px; color: rgb(0, 153, 0); font-size: inherit; word-break: break-all;">"msgid"</span>: <span class="hljs-string" style="outline: 0px; color: rgb(0, 153, 0); font-size: inherit; word-break: break-all;">"5B5809F9000022C7"</span>
}

OK</code><ul class="pre-numbering" style="outline: 0px; padding-top: 8px; padding-bottom: 8px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-size: inherit; word-break: break-all; position: absolute; width: 48px; background-color: rgb(238, 240, 244); top: 0px; left: 0px; text-align: right;"><li style="outline: 0px; padding: 0px 8px; margin: 0px; font-size: inherit; list-style: none; word-break: break-all; color: rgb(153, 153, 153);">1</li><li style="outline: 0px; padding: 0px 8px; margin: 0px; font-size: inherit; list-style: none; word-break: break-all; color: rgb(153, 153, 153);">2</li><li style="outline: 0px; padding: 0px 8px; margin: 0px; font-size: inherit; list-style: none; word-break: break-all; color: rgb(153, 153, 153);">3</li><li style="outline: 0px; padding: 0px 8px; margin: 0px; font-size: inherit; list-style: none; word-break: break-all; color: rgb(153, 153, 153);">4</li><li style="outline: 0px; padding: 0px 8px; margin: 0px; font-size: inherit; list-style: none; word-break: break-all; color: rgb(153, 153, 153);">5</li><li style="outline: 0px; padding: 0px 8px; margin: 0px; font-size: inherit; list-style: none; word-break: break-all; color: rgb(153, 153, 153);">6</li><li style="outline: 0px; padding: 0px 8px; margin: 0px; font-size: inherit; list-style: none; word-break: break-all; color: rgb(153, 153, 153);">7</li><li style="outline: 0px; padding: 0px 8px; margin: 0px; font-size: inherit; list-style: none; word-break: break-all; color: rgb(153, 153, 153);">8</li><li style="outline: 0px; padding: 0px 8px; margin: 0px; font-size: inherit; list-style: none; word-break: break-all; color: rgb(153, 153, 153);">9</li><li style="outline: 0px; padding: 0px 8px; margin: 0px; font-size: inherit; list-style: none; word-break: break-all; color: rgb(153, 153, 153);">10</li><li style="outline: 0px; padding: 0px 8px; margin: 0px; font-size: inherit; list-style: none; word-break: break-all; color: rgb(153, 153, 153);">11</li><li style="outline: 0px; padding: 0px 8px; margin: 0px; font-size: inherit; list-style: none; word-break: break-all; color: rgb(153, 153, 153);">12</li><li style="outline: 0px; padding: 0px 8px; margin: 0px; font-size: inherit; list-style: none; word-break: break-all; color: rgb(153, 153, 153);">13</li><li style="outline: 0px; padding: 0px 8px; margin: 0px; font-size: inherit; list-style: none; word-break: break-all; color: rgb(153, 153, 153);">14</li><li style="outline: 0px; padding: 0px 8px; margin: 0px; font-size: inherit; list-style: none; word-break: break-all; color: rgb(153, 153, 153);">15</li><li style="outline: 0px; padding: 0px 8px; margin: 0px; font-size: inherit; list-style: none; word-break: break-all; color: rgb(153, 153, 153);">16</li><li style="outline: 0px; padding: 0px 8px; margin: 0px; font-size: inherit; list-style: none; word-break: break-all; color: rgb(153, 153, 153);">17</li><li style="outline: 0px; padding: 0px 8px; margin: 0px; font-size: inherit; list-style: none; word-break: break-all; color: rgb(153, 153, 153);">18</li><li style="outline: 0px; padding: 0px 8px; margin: 0px; font-size: inherit; list-style: none; word-break: break-all; color: rgb(153, 153, 153);">19</li><li style="outline: 0px; padding: 0px 8px; margin: 0px; font-size: inherit; list-style: none; word-break: break-all; color: rgb(153, 153, 153);">20</li><li style="outline: 0px; padding: 0px 8px; margin: 0px; font-size: inherit; list-style: none; word-break: break-all; color: rgb(153, 153, 153);">21</li><li style="outline: 0px; padding: 0px 8px; margin: 0px; font-size: inherit; list-style: none; word-break: break-all; color: rgb(153, 153, 153);">22</li><li style="outline: 0px; padding: 0px 8px; margin: 0px; font-size: inherit; list-style: none; word-break: break-all; color: rgb(153, 153, 153);">23</li><li style="outline: 0px; padding: 0px 8px; margin: 0px; font-size: inherit; list-style: none; word-break: break-all; color: rgb(153, 153, 153);">24</li><li style="outline: 0px; padding: 0px 8px; margin: 0px; font-size: inherit; list-style: none; word-break: break-all; color: rgb(153, 153, 153);">25</li><li style="outline: 0px; padding: 0px 8px; margin: 0px; font-size: inherit; list-style: none; word-break: break-all; color: rgb(153, 153, 153);">26</li><li style="outline: 0px; padding: 0px 8px; margin: 0px; font-size: inherit; list-style: none; word-break: break-all; color: rgb(153, 153, 153);">27</li><li style="outline: 0px; padding: 0px 8px; margin: 0px; font-size: inherit; list-style: none; word-break: break-all; color: rgb(153, 153, 153);">28</li><li style="outline: 0px; padding: 0px 8px; margin: 0px; font-size: inherit; list-style: none; word-break: break-all; color: rgb(153, 153, 153);">29</li><li style="outline: 0px; padding: 0px 8px; margin: 0px; font-size: inherit; list-style: none; word-break: break-all; color: rgb(153, 153, 153);">30</li><li style="outline: 0px; padding: 0px 8px; margin: 0px; font-size: inherit; list-style: none; word-break: break-all; color: rgb(153, 153, 153);">31</li><li style="outline: 0px; padding: 0px 8px; margin: 0px; font-size: inherit; list-style: none; word-break: break-all; color: rgb(153, 153, 153);">32</li><li style="outline: 0px; padding: 0px 8px; margin: 0px; font-size: inherit; list-style: none; word-break: break-all; color: rgb(153, 153, 153);">33</li><li style="outline: 0px; padding: 0px 8px; margin: 0px; font-size: inherit; list-style: none; word-break: break-all; color: rgb(153, 153, 153);">34</li><li style="outline: 0px; padding: 0px 8px; margin: 0px; font-size: inherit; list-style: none; word-break: break-all; color: rgb(153, 153, 153);">35</li><li style="outline: 0px; padding: 0px 8px; margin: 0px; font-size: inherit; list-style: none; word-break: break-all; color: rgb(153, 153, 153);">36</li><li style="outline: 0px; padding: 0px 8px; margin: 0px; font-size: inherit; list-style: none; word-break: break-all; color: rgb(153, 153, 153);">37</li><li style="outline: 0px; padding: 0px 8px; margin: 0px; font-size: inherit; list-style: none; word-break: break-all; color: rgb(153, 153, 153);">38</li><li style="outline: 0px; padding: 0px 8px; margin: 0px; font-size: inherit; list-style: none; word-break: break-all; color: rgb(153, 153, 153);">39</li></ul>

可以看到已经成功发送出去。需要注意的是post的内容需要对中文进行utf-8的url编码 

从上面Luat和AT的例子可以看出,在完成较复杂逻辑的时候,Luat明显优于AT命令。


转载请注明原文链接:使用物联网卡发送短信
喜欢 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址