pyapns - hexlified_token_str

时间:2010-09-30 19:11:57

标签: python apple-push-notifications

我尝试测试pyapns

文档中提到了 hexlified_token_str 。 我的令牌以base64格式存储。

我尝试这样做

>>> notify('myapp', base64.decodestring('Sl96FJtZbZDZECSP3EedQJbsXdtlV+LXWd4+jbzvbHM='), {'aps':{'alert': 'Hello!'}})

但我错了。

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "build/bdist.linux-i686/egg/pyapns/client.py", line 54, in notify
  File "build/bdist.linux-i686/egg/pyapns/client.py", line 76, in _xmlrpc_thread
  File "/usr/lib/python2.5/xmlrpclib.py", line 1147, in __call__
    return self.__send(self.__name, args)
  File "/usr/lib/python2.5/xmlrpclib.py", line 1437, in __request
    verbose=self.__verbose
  File "/usr/lib/python2.5/xmlrpclib.py", line 1201, in request
    return self._parse_response(h.getfile(), sock)
  File "/usr/lib/python2.5/xmlrpclib.py", line 1340, in _parse_response
    return u.close()
  File "/usr/lib/python2.5/xmlrpclib.py", line 787, in close
    raise Fault(**self._stack[0])
  xmlrpclib.Fault: <Fault 8002: "Can't deserialize input: not well-formed (invalid token): line 9, column 18">

如何正确地进行己基化?

1 个答案:

答案 0 :(得分:1)

昨天为时已晚...... 它完成了这项工作:

binascii.hexlify(base64.decodestring('Sl96FJtZbZDZECSP3EedQJbsXdtlV+LXWd4+jbzvbHM='))

这只是一个过时的令牌!