0
我想發短信,我讓我這樣無效的模板
{ 「錯誤」:[{ 「代碼」:80, 「消息」: 「無效的模板」}], 「狀態」:」失敗「}
我的代碼是:
def sending_sms(number,message):
url = 'http://api.textlocal.in/send/'
msg = message
post_fields=({"username":"*********","password":"******","numbers":number,"message":msg})
request = Request(url, urlencode(post_fields).encode())
print request
json = urlopen(request).read().decode()
print json
return json
這個問題和django有關係嗎?您可以使用[請求](http://docs.python-requests.org/en/master/)庫。 – trixn
好的,謝謝你的建議,如何解決這個錯誤 – praveenjp
你應該學習你正在使用的服務的[api文檔](http://api.textlocal.in/docs/)。據我所見,這個錯誤是無證的。所以很難猜測你的請求失敗的原因。但是他們的[python示例](http://api.textlocal.in/docs/sendsms)在url的末尾有一個'?'。像這樣''「http://api.textlocal.in/send/?」' – trixn