我想将一些 POST 数据发送到将在 twilio 调用中建立连接后调用的 url。这是我的代码:
import urllib, urllib2
from twilio.rest import TwilioRestClient
account = "xxx"
token = "xxx"
client = TwilioRestClient(account, token)
server_url = "http://ec2-xx.xx.xx.compute-1.amazonaws.com/"
values = dict(name='mytime', \
appt_time='2:30 PM', \
location='Arizona Location', \
client = "Suwanee",
)
data = urllib.urlencode(values)
req = urllib2.Request(server_url, data)
call = client.calls.create(to="123456789",
from_="987654321",
url="ec2-xx.xx.xx.compute-1.amazonaws.com/hello/")
我如何将 urlencodeddata
作为帖子传递给 url?
ec2-xx.xx.xx.compute-1.amazonaws.com 正在运行 django,当我发送以下命令时,此服务器能够看到发布数据:
curl -X POST -d "client=mytime+Suwanee&time=2%3A30+PM&location=Suwanee+Location&name=mytime2" "http://127.0.0.1:8000/remind/"
如何在开头提供的代码片段中复制相同的行为?我只想使用 POST(而不是 GET)。