現在我有一個程序接收一條SMS消息,發佈消息正文,然後將SMS轉發給另一個號碼。但是,我收到Twilio關於「Scheme驗證」的錯誤。代碼的功能與它應該完全一樣,但我想修復錯誤。Twilio/Python - 12200架構驗證警告
起初,我有以下代碼:
import RUAlertsTwilioWEBSERVER
import twilio.twiml
import time
import praw
from flask import Flask, request, redirect
from twilio.rest import TwilioRestClient
from passwords import *
from twilio import twiml
def login():
r = praw.Reddit(app_ua)
r.set_oauth_app_info(app_id, app_secret, app_uri)
r.refresh_access_information(app_refresh)
return r
r=RUAlertsTwilioWEBSERVER.login()
client = TwilioRestClient(account_sid, auth_token)
app = Flask(__name__)
@app.route("/", methods=['GET', 'POST'])
def AlertService():
TheMessage=request.form.get("Body")
if (TheMessage != None):
print(TheMessage)
client.messages.create(to=ePhone,from_=tPhone,body=str(TheMessage))
r.submit(*submit to reddit code*)
return str(TheMessage)
if __name__ == "__main__":
app.run(debug=True, host="0.0.0.0")
的Twilio調試器給我 Content is not allowed in prolog. Warning - 12200 Schema validation warning The provided XML does not conform to the Twilio Markup XML schema.
我試圖改變我的代碼以下獲得所需職位的XML(只有相關部分)
@app.route("/", methods=['GET', 'POST'])
def AlertService():
TheMessage=request.form.get("Body")
if (TheMessage != None):
print(TheMessage)
resp = twiml.Response()
XML = resp.say(TheMessage)
client.messages.create(to=ePhone,from_=tPhone,body=XML)
r.submit(*submit to reddit code*)
return str(resp)
return str(TheMessage)
此代碼沒有工作,所以我改變body=XML
到body=str(XML)
。但現在它只是發送XML作爲正文,並且收到錯誤: cvc-complex-type.2.4.a: Invalid content was found starting with element 'Say'. One of '{Sms, Message, Redirect}' is expected. Warning - 12200 Schema validation warning The provided XML does not conform to the Twilio Markup XML schema.
如何解決此問題?
對不起,我不清楚這一點。我想將發送給Twilio的SMS正文轉發給另一個第三個號碼(不是發件人或Twilio號碼)。 當我使用「說」只是爲了獲得XML格式。 這段代碼'client.messages.create(to = ePhone,from_ = tPhone,body = TheMessage)'有效,但我仍然從調試器中得到錯誤。 –
@DevinRader你能檢查我的問題嗎?謝謝http://stackoverflow.com/questions/43367898/twilio-quick-start-project-is-not-working –