python 3.4 use python-gcm can't import

Mark Lawrence breamoreboy at yahoo.co.uk
Fri Aug 29 12:51:28 EDT 2014


On 29/08/2014 09:35, Frank Liou wrote:
> what?
>
> So...My 3.4 can't use this package?
>
> now
>
> i use http.client
>
>              reg_ids = []
>              reg_ids.append(GetCustomerGCMId[0])
>              API_KEY = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
>              mydata = {'registration_ids': reg_ids, 'data': data}
>              jqs = json.dumps(mydata)
>              headers = {"Content-type": "application/json", "Authorization": "key="+API_KEY}
>              conn = http.client.HTTPConnection('android.googleapis.com')
>              conn.request('POST', '/gcm/send', jqs, headers)
>              res = conn.getresponse()
>              conn.close()
>              reason = res.reason
>              read = res.read().decode()
>              headers = res.headers
>              result = {'msg': res.status, 'reason': str(res.reason), 'read': str(res.read())}
>
>
> i got status only 200 ok
>
> and body is "b'" .....is empty
>
> i'm so confused.don't know it work or not
>

Thankfully I've one of my crystal balls back from the menders so I know 
that you're responding to Ian Kelly.  Having said that have you tried 
running the code through 2to3?

-- 
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence




More information about the Python-list mailing list