Open SourcePHPXMPP

How to perform X-FACEBOOK-PLATFORM and Google Talk X-OAUTH2 XMPP authentication with PHP Jaxl library

Ever since Jaxl library first introduced support for X-FACEBOOK-PLATFORM XMPP authentication mechanism, it has changed significantly. Also, Google Talk now supports OAuth 2.0 Authorization, an XMPP extension to allow users to log in using OAuth 2.0 credentials.

Both these mechanisms are a big win for XMPP developers, since real-time conversation experience can now be provided to their application users without asking them for their passwords. In this blog post, I will demonstrate how to perform X-FACEBOOK-PLATFORM and X-OAUTH2 XMPP authentication mechanism using Jaxl v3.x PHP Library.

X-FACEBOOK-PLATFORM XMPP Authentication
Here is a quick guide on how to perform X-FACEBOOK-PLATFORM XMPP authentication using xfacebook_platform_client.php which comes bundled with Jaxl v3.x examples:

  • Visit Facebook Developer Apps page and register your application
  • Once registered, visit access token tool to get required parameters to perform X-FACEBOOK-PLATFORM authentication Facebook Access Token Tool
  • Click on the debug button next to User Token and make sure xmpp_login is one of the extended permissions (scope)
  • Enter downloaded Jaxl library folder and run from command line as follows:

    $ php examples/xfacebook_platform_client.php fb_user_id_or_username fb_app_key fb_access_token

You can now take the source code of xfacebook_platform_client.php and customize it for your application needs.

Google Talk X-OAUTH2 XMPP Authentication
Here is a quick guide on how to perform Google Talk X-OAUTH2 XMPP authentication using xoauth2_gtalk_client.php which comes bundled with Jaxl v3.x examples:

  • Visit Google OAuth Playground and input https://www.googleapis.com/auth/googletalk as the required scope. Press “Authorize API” and then “Allow Access” button on the redirected page
  • In step 2, simply press “Exchange authorize code for tokens” and copy the access token
  • Enter downloaded Jaxl library folder and run from command line as follows:

    $ php examples/xoauth2_gtalk_client.php [email protected] access_token

You can now take the source code of xoauth2_gtalk_client.php and customize it for your application needs.

Wasn’t that simple 🙂

21 thoughts on “How to perform X-FACEBOOK-PLATFORM and Google Talk X-OAUTH2 XMPP authentication with PHP Jaxl library

  1. Hii..

    Great work, I was trying registering an app for x-facebook-authentication but i am confused with app scope please suggest what sholud be taken from below points :

    1) Website with Facebook Login

    2)App on Facebook

    3)Mobile Web

    4)Native iOS App

    5)Native Android App

    6)Page Tab

    Please reply

  2. Hii..

    Great work, I was trying registering an app for x-facebook-authentication but i am confused with app scope please suggest what sholud be taken from below points :

    1) Website with Facebook Login

    2)App on Facebook

    3)Mobile Web

    4)Native iOS App

    5)Native Android App

    6)Page Tab

    Please reply

  3. Hi there.

    I tried to get it work, but i can’t make it.

    I want to perform inside of a PHP workflow to send a chat message to Facebook. I already have a Token, i have xmpp_login rights, but there is no way to get a message to facebook.

    Is there any small code snippet which can help me understand how i can make it?

    Thanks in advance
    Bavaglino

  4. Hi there.

    I tried to get it work, but i can’t make it.

    I want to perform inside of a PHP workflow to send a chat message to Facebook. I already have a Token, i have xmpp_login rights, but there is no way to get a message to facebook.

    Is there any small code snippet which can help me understand how i can make it?

    Thanks in advance
    Bavaglino

  5. We (super feeder) have a similar web app where XMPP is part of the application. The choice we made is to not replicate the user data across both the web app storage and the XMPP server. You can build your own authentication mechanism using the web app’s data store with e-jabbered, it’s pretty easy. This way, you only have 1 single place where user data is …

  6. We (super feeder) have a similar web app where XMPP is part of the application. The choice we made is to not replicate the user data across both the web app storage and the XMPP server. You can build your own authentication mechanism using the web app’s data store with e-jabbered, it’s pretty easy. This way, you only have 1 single place where user data is …

  7. Hi Abhinav,

    I got the gtalk client to work in the command line (BTW it wasn’t working because the sample client script didn’t have the host and port for gtalk). Anyway, I don’t really need a client for chatting, all I want to do is set the presence to dnd and exit. Then later run it again and set the presence back to what it was and exit.

    How do you suggest I accomplish this?

  8. Hi Abhinav,

    I got the gtalk client to work in the command line (BTW it wasn’t working because the sample client script didn’t have the host and port for gtalk). Anyway, I don’t really need a client for chatting, all I want to do is set the presence to dnd and exit. Then later run it again and set the presence back to what it was and exit.

    How do you suggest I accomplish this?

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.