我得到的答复是:
{“错误”:{“代码”:204,“消息”:“无效消息内容”},“状态”:“失败”}
当我尝试使用此模板提交消息时,我已向Textlocal注册:
谢谢你在*登记。请输入验证代码%%\OTP^{“inputtype”:"text“、"maxlength”:“6”}%以完成注册。
如何使用此模板发送消息?我目前的代码是:
def sending_sms(number,otp):
url = 'http://api.textlocal.in/send/'
msg = 'Thank you for registering with RTM. Please enter the verification code %%|OTP^{"inputtype" : "text", "maxlength" : "6"}%% to complete the registration.'
post_fields = ({"username":"admin@example.in","password":"P@ssword","numbers":number,"message":msg})
request = Request(url, urlencode(post_fields).encode())
print request
json = urlopen(request).read().decode()
print json
return json发布于 2017-02-04 07:20:30
您正在将模板作为您的消息发送。您需要发送一个填充模板(即替换实际的OTP代码,而不是%%|OTP... )。
从医生那里:
如何通过API?发送模板 Textlocal根据所有已批准的模板检查您的邮件,只有当消息与您帐户中的任何已批准模板完全匹配时,才会传递该消息。
Thank you for registering with Textlocal. Your verification code is XXXX
需要传递的消息内容是:Thank you for registering with Textlocal. Your verification code is 1123
(其中代码由应用程序生成)
$message = rawurlencode('Thank you for registering with Textlocal. Your verification code is $otp')
其中$otp是动态参数代码中的标识符。
值得注意的一点:
发布于 2020-12-15 08:45:01
是的,根据@Grisha Levit的答案。您只需在消息变量本身中发送OTP,而不是%%扣分OTP^{“inputtype”:"text","maxlength“:”6“}%。
解决这个问题
改变这个
msg = 'Thank you for registering with RTM. Please enter the verification code %%|OTP^{"inputtype" : "text", "maxlength" : "6"}%% to complete the registration.'对此
otp = 123456
msg = 'Thank you for registering with RTM. Please enter the verification code {otp} to complete the registration.'https://stackoverflow.com/questions/42036628
复制相似问题