谷歌云消息传递了XMPP协议(使用PHP和XMPPHP的服务器的工作)。它是如何工作的?工作、它是、协议、消息

2023-09-05 07:00:08 作者:矫情滚开

也许你已经听说过它。这是在谷歌的IO,也许一个月前公布。谷歌云消息传递只有下游(服务器 - >电话),但现在随着增强CCS(云连接的服务器),你可以在持久的TCP连接的感谢XMPP协议上行发送消息。我已经设计了与GCM和HTTP运行的应用程序。它使用GCM库,并且在有包装(如GCMRegistrar)类。这个班。如今,precated,和谷歌recomends使用GoogleCloudMessaging API,而不是。

maybe you heard already about it. It was announced at the Google IO maybe one month ago. Google Cloud Messaging was only downstream (server --> phone), but now with the enhancement CCS (cloud connection server) you can send messages upstream over a persistent TCP connection thanks the XMPP protocol. I have already designed an application which works with GCM and HTTP. It uses the gcm library and the classes that are packed in there (like GCMRegistrar). This classes are now deprecated, and Google recomends to use the GoogleCloudMessaging API instead.

现在一切工作有点不同。你有谷歌文档和他们解释非常好,你可以如何设计你的Andr​​oid应用程序。但我有问题的服务器,因为我以前从来没有与XMPP。他们给Python中的code在这里: http://developer.android.com/google/gcm/gs.html 但我不知道在Python的。所以,我调查了,然后我找到了XMPPHP库。然后,您可以用PHP,并使用该库与XMPP连接和发送/接收消息。

Everything works a little bit different now. You have the Google documentation and they explain very good, how you can design your Android App. BUT I have problems with the server, because I have never worked with XMPP before. They give a code in Python here: http://developer.android.com/google/gcm/gs.html but I have no idea over Python. So I investigated and then I found the XMPPHP library. You can then work with PHP and use the library to connect with XMPP and send/receive messages.

我与它没有任何工作经验,并doesn't工作给我。我怎样才能打开与谷歌XMPP服务器建立XMPP连接?

I have no experience working with it and it doesn´t work to me. How can I open a XMPP connection with the Google XMPP server?

我发现这种方式打开一个连接(在这里你一起工作的库):

I found this way to open a connection (here you work with the library):

$conn = new XMPPHP_XMPP($host, $port, $user, $password, $resource, $server, $printlog, $loglevel);

有谁知道哪些参数我要在这里传递,以便与谷歌CCS ??连接

Does anyone know which parameters do I have to pass here in order to connect with Google CCS??

我想知道的太多:

我如何发送一条消息通过XMPP到设备? 我怎样才能收到一条消息,从设备??

How I send a message over XMPP to a device? How can I receive a message from a device??

推荐答案

我碰到了同样的问题,尝试使用XMPPHP,但后来发现JAXL库,并切换到它。请参阅unable连接到谷歌云连接服务器。 JAXL可以让你观看它发送,使用特殊的调试模式'LOG_LEVEL'=> JAXL_DEBUG 。然后,我看到了谷歌送我这样的:

I run into the same problem, tried using XMPPHP, but then discovered JAXL library and switched to it. See unable to connect to Google Cloud Connection Server. JAXL allows you to watch what it sends, using special debug mode 'log_level' => JAXL_DEBUG. Then I saw that Google sends me this:

<failure xmlns="urn:ietf:params:xml:ns:xmpp-sasl"><temporary-auth-failure/><text xmlns="urn:ietf:params:xml:ns:xmpp-stanzas">Project 1945693724760 not whitelisted.</text></failure>

这是我无法发送任何通知的原因。你应该先注册CCS在这里: https://services.google.com/fb/forms/ GCM / 。

That was the reason I couldn't send any notifications. You should first register for CCS here: https://services.google.com/fb/forms/gcm/.