Google Cloud Messaging over XMPP protocol (server working with PHP and XMPPHP). How does it work?

大兔子大兔子 提交于 2019-12-21 02:21:28

问题


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.

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.

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);

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

I would like to know too:

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


回答1:


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>

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



来源:https://stackoverflow.com/questions/17164305/google-cloud-messaging-over-xmpp-protocol-server-working-with-php-and-xmpphp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!