當我嘗試通過GCM發送消息時,我總是收到一個空的json響應{}
。使用python-gcm的空json響應
我使用python-gcm,這是我的代碼:
from gcm import GCM
API_KEY = "AldaSyAwnh5jAAAAAAABvBTyqDdMITCoEE8GLZ"
my_gcm = GCM(api_key=API_KEY)
data = {'param1': 'value1', 'param2': 'value2'}
# JSON request
#reg_ids = ['12', '34', '69']
reg_ids = ['ALA91bE9QSkVKcmAAAAAAda8UsNs27R-29pJHDqwIiwqxSAStmhpFo2hKD0SipoCjgANvFJ7trdQZuJCjMaUAAAA6zmETYDncD9YTiVZ61eG1pwXdOJC7mozlt76OoyM81OasWi9_ibGklNfhWGhJpg']
response = my_gcm.json_request(registration_ids=reg_ids, data=data)
# Handling errors
if 'errors' in response:
for error, reg_ids in response['errors'].items():
# Check for errors and act accordingly
if error is 'NotRegistered':
# Remove reg_ids from database
for reg_id in reg_ids:
entity.filter(registration_id=reg_id).delete()
if 'canonical' in response:
for reg_id, canonical_id in response['canonical'].items():
# Repace reg_id with canonical_id in your database
entry = entity.filter(registration_id=reg_id)
entry.registration_id = canonical_id
entry.save()
我在做什麼錯了,我應該嘗試另一種選擇? 其他細節:
- 我在用燒瓶。
在我的開發者谷歌控制檯我有谷歌地圖
也被激活。
@MartijnPieters是瘋了,只是爲了確保我使用正確的值。 – Ricardo 2015-01-04 13:56:25
很好,但是從您發佈的內容中不清楚。 :-) – 2015-01-04 13:57:35