Google Cloud Messaging via XMPP (server working with PHP and XMPPHP). How it works?

You may have already heard about this. This was announced on Google IO, perhaps a month ago. Google cloud messages were only downstream (server β†’ phone), but now with CCS (cloud computing server) you can send messages upstream through a permanent TCP connection thanks to the XMPP protocol. I have already developed an application that works with GCM and HTTP. It uses the gcm library and the classes that are packed there (e.g. GCMRegistrar). These classes are now deprecated, and Google recommends using the GoogleCloudMessaging API.

Now everything works a little differently. You have Google documentation and they explain very well how you can design your Android app. BUT I have problems with the server, because I have never worked with XMPP before. Here they give the code in Python: http://developer.android.com/google/gcm/gs.html but I have no idea about Python. So I researched and then found the XMPPHP library. Then you can work with PHP and use the library to connect to XMPP and send / receive messages.

I have no experience with him and it does not work for me. How to open an XMPP connection with a Google XMPP server?

I found this way to open the connection (here you are working with the library):

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

Does anyone know what parameters I need to pass here in order to contact Google CCS?

I would also like to know:

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

+7
source share
1 answer

I ran into the same problem, tried using XMPPHP, but then I discovered the JAXL library and switched to it. See Unable to connect to Google Cloud Connection Server . JAXL allows you to watch what it sends using the special debug mode 'log_level' => JAXL_DEBUG . Then I saw that Google sent 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> 

It was for this reason that I could not send any notifications. You must first register for CCS here: https://services.google.com/fb/forms/gcm/ .

+2
source

All Articles