forked from pr0gg3d/txgcm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
__init__.py
29 lines (23 loc) · 881 Bytes
/
__init__.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
print "a"
from pygcm.client import GcmClient as _GcmClient
from pygcm.client import HTTPClient
from twisted.web.client import getPage
class TwistedHttpClient(HTTPClient):
def send(self, api_key, registration_ids, send_data):
def cb(result):
return self._handler.load(result)
def eb(failure):
return
d = getPage(
self.url,
method='POST',
postdata=self._handler.dump(registration_ids, send_data),
headers={
'Content-Type': self._handler.content_type,
'Authorization': 'key=%s' % api_key,
})
d.addCallbacks(cb, eb)
return d
class GcmClient(_GcmClient):
def __init__(self, api_key, mode='json', client=TwistedHttpClient):
super(GcmClient, self).__init__(api_key, client=client)