我有下面的代码,我试图用Pushalot Apias Pushalot向Windows Phone发送消息,但没有任何示例。你知道吗
我知道我的api密钥工作正常,因为cURL方法工作正常,但是我修改过的python脚本不工作,继续得到--400,错误的请求,我不知道为什么。你知道吗
有什么想法吗?你知道吗
#!/usr/bin/python
from urllib import urlencode
from httplib import HTTPSConnection, HTTPException
from ssl import SSLError
pushalot_authorizationtoken = 'xxxxxxxxxxxxxxx'
pushalot_title = 'title'
pushalot_body = 'body'
http_handler = HTTPSConnection("pushalot.com")
data = {'AuthorizationToken': pushalot_authorizationtoken,
'Title': pushalot_title.encode('utf-8'),
'Body': pushalot_body.encode('utf-8') }
try:
http_handler.request("POST",
"/api/sendmessage",
headers = {'Content-type': "application/x-www-form-urlencoded"},
body = urlencode(data))
except (SSLError, HTTPException):
print("Pushalot notification failed.")
response = http_handler.getresponse()
print(response.status, response.reason)
今天工作,奇怪,上面的代码工作。你知道吗
其他需要pushalotapi的python代码的人可以使用这个
相关问题 更多 >
编程相关推荐