这是编写 CCS 服务器的 Google 文档中的 python 代码:
https://developer.android.com/google/gcm/gs.html#server
我想出了其中的大部分,以及如何使用https://github.com/astro/node-xmpp在 Javascript 中对其进行编码
但我无法理解如何使用模板发送数据,正是这部分代码:
def send(json_dict):
  template = ("<message><gcm xmlns='google:mobile:data'>{1}</gcm></message>")
  client.send(xmpp.protocol.Message(
      node=template.format(client.Bind.bound[0], json.dumps(json_dict))))
在 node-xmpp 中,发送是通过以下方式完成的:
var cl = new xmpp.Client({ jid: username,
                           password: password });
cl.addListener('online',
               function() {
                   argv.slice(5).forEach(
                       function(to) {
                           cl.send(new xmpp.Element('message',
                                                    { to: to,
                                                      type: 'chat'}).
                                   c('body').
                                   t(argv[4]));
                       });
我了解正在发送的 JSON,但我无法绑定他们在 Python 中管理的模板。有什么帮助吗?