python gcm channel_python – 无法使用Django在GCM中发送POST请求

这是我的看法:

@csrf_exempt

def send_notification(request):

message = {"name": "xxxxx","email": "xxxxxx@gmail.com"}

registration_ids = ['xxxxxxxxxxxxxx']

post_data = {"data":message,"registration_ids":registration_ids}

headers = {'Content-Type': 'application/json', 'Authorization':'key=xxxxxx'}

import requests

post_response = requests.post(url='https://android.googleapis.com/gcm/send', data=simplejson.dumps(post_data), headers=headers)

print post_response

print simplejson.dumps([post_response.headers, post_response.text])

to_json = {'status':str(post_response)}

return HttpResponse(simplejson.dumps(to_json), mimetype='application/json')

服务器日志:

[error]

输出:

TypeError at /send_notification/

CaseInsensitiveDict(

{

"alternate-protocol": "443:quic",

"x-xss-protection": "1; mode=block",

"x-content-type-options": "nosniff",

"transfer-encoding": "chunked",

"expires": "Fri, 08 Nov 2013 10:29:45 GMT",

"server": "GSE",

"cache-control": "private, max-age=0",

"date": "Fri, 08 Nov 2013 10:29:45 GMT",

"x-frame-options": "SAMEORIGIN",

"content-type": "text/html; charset=UTF-8"

}) is not JSON serializable

我正在使用的请求只给出了上述内容.

我也试过测试其他工作的网址!

怎么可能出错?

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值