This isn't done and it's barely passable as workable code, but it runs and gives you the device tokens from the feedback service.
Code:
#!/usr/bin/env python2.6
import socket, ssl, json, struct
def uniquify(seq):
set = {}
map(set.__setitem__, seq, [])
return set.keys()
theCertfile = 'dist_cert.pem'
theHost = ('feedback.push.apple.com', 2196)
#theCertfile = 'dev_cert.pem'
#theHost = ('feedback.sandbox.push.apple.com', 2196)
ssl_sock = ssl.wrap_socket(socket.socket(socket.AF_INET, socket.SOCK_STREAM), certfile=theCertfile)
ssl_sock.connect(theHost)
f = ssl_sock.read(2048) #Not sure what size this should be, I think 2 MB should be enough
ssl_sock.close()
array = f.split(' ')
array.pop(0)
tokenstring = ''
tokenarray = []
for hextoken in array:
if len(hextoken) == 37:
unpacked = struct.unpack('!BH34B', hextoken)
for value in unpacked:
converted = hex(value)[2:]
if (len(converted) % 2) == 1:
converted = '0' + converted
tokenstring = tokenstring + converted
tokenstring = tokenstring[0:64]
elif len(hextoken) == 32:
unpacked = struct.unpack('!BH29B', hextoken)
for value in unpacked:
converted = hex(value)[2:]
if (len(converted) % 2) == 1:
converted = '0' + converted
tokenstring = tokenstring + converted
tokenarray.append(tokenstring)
tokenstring = ''
print uniquify(tokenarray)