Created
July 11, 2009 14:09
-
-
Save leepa/145257 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import struct | |
from socket import socket | |
import ssl | |
import binascii | |
payload = '{"aps":{"alert":"Hello World","sound":"chime"}}' | |
fmt = "!cH32sH%ds" % len(payload) | |
command = '\x00' | |
token = '<<removed>>' | |
msg = struct.pack(fmt, command, 32, binascii.unhexlify(token), len(payload), payload) | |
s = socket() | |
c = ssl.wrap_socket(s, | |
ssl_version=ssl.PROTOCOL_SSLv3, | |
certfile='ck.pem') | |
c.connect(('gateway.sandbox.push.apple.com', 2195)) | |
c.write(msg) | |
c.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment