我刚刚开始使用 Plivo 设置短信服务。我试图在我的服务器上接收短信,但我的服务器似乎没有收到它们。
我已经在heroku上设置了它,下面是我的代码:import plivo, plivoxml import os import os.path from flask import Flask, request
app = Flask(__name__)
@app.route("/receive-sms/",methods=['GET','POST'])
def inbound_sms():
# Sender's phone number
from_number = request.values.get('From')
print from_number
# Receiver's phone number - Plivo number
to_number = request.values.get('To')
# The text which was received
text = request.values.get('Text')
params = {
"src": to_number,
"dst": from_number,
}
body = "Thanks, we've received your message."
# Generate a Message XML with the details of
# the reply to be sent.
r = plivoxml.Response()
r.addMessage(body, **params)
return r.to_xml()
if __name__ == "__main__":
port = int(os.environ.get('PORT', 5000))
# print port
app.run(host='0.0.0.0', port=port)
在 Plivo 上,我的消息网址是: http ://ripmac.herokuapp.com/receive-sms/
我已将我的 Plivo 号码链接到正确的 plivo 应用程序。
此外,我不确定当我登录 Plivo 并导航到日志-> SMS 时是否应该看到消息。没有日志让我开始认为端口/消息 url 有问题。任何帮助都感激不尽。谢谢!