Facebook chat connect with X-FACEBOOK-PLATFORM using Jaxl 2.0

Facebook chat connect with X-FACEBOOK-PLATFORM using Jaxl 2.0

Facebook chat provides two authentication mechanisms for authenticating chat client users. DIGEST-MD5 require chat client users to enter their username and password, while X-FACEBOOK-PLATFORM can be used to provide better user experience by using simple Facebook Platform authentication. In this blog post, I will demonstrate how to use Jaxl library for X-FACEBOOK-PLATFORM authentication.

Setup Jaxl library on your system and edit packaged sample echobot application with facebook user account details. Alternately you can also specify connecting user details inside jaxl.ini configuration file.

        $jaxl = new JAXL(array(
                'pass'=>'', // Not required, we will use user session key instead

Add callback for hook jaxl_get_facebook_key:

JAXLPlugin::add('jaxl_get_facebook_key', array($echobot, 'getFacebookKey'));

Complete getFacebookKey method inside echobot application, which should return back following key information:

function getFacebookKey() {
                        return array(
                                '', // Your application secret key
                                '', // Your application api key
                                '' // Connecting user session key

Update doAuth method to use X-FACEBOOK-PLATFORM auth mechanism:

                function doAuth($mechanism) {
                        global $jaxl;

Finally, run echobot from command line:

[email protected]:/usr/share/php/jaxl/app/echobot# jaxl echobot.php
[1942] 2010-08-08 05:35:10 - Socket opened to the jabber host chat.facebook.com:5222 ...
[1942] 2010-08-08 05:35:11 - Performing Auth type: X-FACEBOOK-PLATFORM
[1942] 2010-08-08 05:35:26 - Auth completed...


  1. samual

    Hi Abhinav,

    I am using JAXL library jaxl-2.0 ,jaxl-2.0.0.tar.gz (downloaded from http://code.google.com/p/jaxl/downloads/list ) for one of my facebook connect applications to use facebook chat, I want to use X-FACEBOOK-PLATFORM authentication I followed all the above steps, my questions are
    (1)is it possible to use email in place of user name because as much i know it is not possible to get username of each facebook user
    (2)I added jaxl_get_facebook_key hook but it never get called.
    (3)I ran echobot,php from command line and for testing provided my facebook session_key and now it hangs at Performing Auth type: X-FACEBOOK-PLATFORM when i looked into log I found following
    [[XMPPSend]] 185

    [[XMPPSend]] 0

    As I can see from here that nothing goes from client to facebok server then i changed startAuth function(not sure doing right)to include the case for X-FACEBOOK-PLATFORM as
    $xml = ”;
    and now again ran echobot.php, this time result Unable to complete SASL Auth, see logs for detail… Jaxl Shutting down … and in log

    pls help me out

  2. samual

    sorry for posting again same post..

    If I use ‘digest-md5’ with facebook password and user name it works fine but as I dont want to let the user re-input their facebook name and password, how could I get their password to use digest-md5 authentication

  3. Kindly use development branch code for using X-FACEBOOK-PLATFORM authentication. http://github.com/abhinavsingh/JAXL

    No, I don’t think email can be used to login into facebook chat, user must have chosen a username. Correct me if I am wrong.

    While using X-FACEBOOK-PLATFORM approach, you need to provide 3 information when jaxl_get_facebook_key is called i.e. api_secret, api_key, and user_session_key.

    You need to obtain user_session_key with extended xmpp_login permissions. http://developers.facebook.com/docs/chat

    No you cannot obtain a user password from user_session_key for use with digest-md5. If you want to skip re-input of username/password, X-FACEBOOK-PLATFORM is the only solution.

    Do let me know how it goes.

  4. Simple enough, use facebook user id instead of username. E.g. http://www.facebook.com/profile.php?id=544265614 leads to http://www.facebook.com/abhinavsingh, hence “-544265614” can be used as my username instead of “abhinavsingh”.

    You get this user id during facebook oauth process, hence never a password must be required for chat connect. Hope it helps.

    #Jaxl 2.0.3 is out!, Includes working #Bosh #Chat example, X-FACEBOOK-PLATFORM auth support. View Changelog http://bit.ly/9YQvXL for details

  5. Pingback: Releasing Jaxl 2.0 – Object oriented XMPP framework in PHP | Abhi's Weblog

  6. Pingback: Jaxl 2.0 Core classes, available methods and directory structure | Abhi's Weblog

  7. Samual

    Hi Abhinav,

    Thankyou so much for your help. I have achieved communcication between my server and fb chat server using X-facebook platform. I want to create a web based chat client for fb chat.

    I have two doubts:-

    1.) Do we have to run jaxl.php for each user seperately or just running it once for all users is fine?

    2). How do I communicate between the browser and fb chat server for frequent updates?
    I can’t do ajax calls as jaxl.php runs continously w/o giving any response. I know it writes log files but how do I send messages to browser…

    Any pointers would be really appreciated. I have been working on this for more than 10 days 🙁

  8. a) If you are running a bosh application, jaxl.php will be invoked every time an ajax is sent from the browser. Jaxl don’t have any one instance architecture for bosh applications, you can’t just run jaxl.php once for all users.

    b) I already answered to your query here before: http://bit.ly/dCYslf on how to communicate with facebook chat servers using browser applications. Try one of the following standalone bosh connection managers:

    JabberHTTPBind http://blog.jwchat.org/jhb/
    Punjab http://code.stanziq.com/punjab/
    Araneo http://blog.bluendo.com/ff/bosh-connection-manager-update
    rhb http://rubyforge.org/projects/rhb/

    Let me know how it goes. 🙂

  9. Samual

    Thanks for the prompt replies but I am still stuck like anything, rather more confused…
    Why do I need a Bosh Connection manager?

    Will simple ajax calls to jaxl.php not suffice?

    Please tell me the major steps I need to do in order to integrate facebook chat on my website using php….

    Can I please have your cell no./chat id so we can have a direct talk?

  10. samual

    hi abhinav,

    Thnx for your so much support…I have successfully implemented jaxl library for xmpp chat , now working on emoctions in chat message any suggestion for this??

  11. Ajay

    Hi Abhinav,

    I am trying to understand and use facebook chat using jaxl.

    When I run the JAXL, the app hangs after Performing Auth type: X-FACEBOOK-PLATFORM.

    The logs show that the app receives the challenge from the server but it does not send a response.

    I am using the latest stable version. Can you please help?


    1. Hi Ajay, Sorry was out on vacation n just back. Can you paste jaxl.log content on pastebin or other online tools so that i can debug in detail. Also from my experience, post Auth, bind/session steps can take time for facebook.com/jabber.org jabber servers.

  12. Ajay

    Hi Abhinav,

    I have tried to fix the issue and have found a fix. The echobot now works with facebook after a few changes in JAXLXml.parse method, though I am not sure if it will break something.

    Maybe it has to do with the version of php (5.1.6) on my servers. You seem to be using a newer version.

    I am sending the changes through email, so that you can review them.


  13. Thanks Ajay. I have received your fix via email and I shall review the same with different versions of PHP on my system and push appropriate fix asap.

    I currently use: PHP 5.2.10-2ubuntu6.4 with Suhosin-Patch 0.9.7 (cli) on my box which has not given any problem till date.

  14. Paul

    I’m wondering if you have any example code for getting roster/presence from Facebook using a session key. I want to do this from in the context of the web, and not the command line.

    I’ve tried to follow your example for the command line, but I was unable to get it to run.

    An example would be immeasurably helpful.


  15. Emmanuel

    hey! Am building a website and i want my vistors to access their facebook chat rooms without having to navigate away from my website. The problem is that i just cant figure out how to exactly do this. Can some one pliz pliz help…i badly need help

  16. Mear diesel

    Hello Abhinav, I have seen that you have updated and committed some new codes into the github. I have installed and do the tutorials but i couldnt make the facebook echo bot run. Could you please, upload a sample “echobot with facebook” ? I have tried also http://abhinavsingh.com/blog/2010/02/writing-your-first-facebook-chat-bot-in-php-using-jaxl-library/ But even i am sure that the username (both used username and facebookid) is correct, it stopped in step : Attempting DIGEST-MD5 Authentication…

    Waiting for a reply from you. Thanks for your efforts!

  17. Yaniv

    Hello Abhinav.

    I’ve got a php wrapper for the JAXL lib, so I can use it through a browser call… However, we’ve been getting lots of requests stuck on G or W mode on apache, which causes lots of hangs on our server… Have you ever encountered it? seems like the request don’t time out correctly, or not shutting down properly…

    1. Hi Yaniv,

      How many concurrent request does you application end up making to the web server?
      Depending upon your application needs you might want to play with apache max child/client and related configurations.
      Would appreciate if you can share your php wrapper so that i can test the things myself.
      If you don’t want to open it up, simply email me if you like to.

  18. Hi Abhinav,

    I have an app that uses your latest JAXL to send a chat message for FB users (FB users will see a popup chat dialog when any kind of messges arrive).

    Problem is this function worked well until a test today. Not sure any changes in FB or your lib?

    Also, I checked file /var/log/jaxl.log.. look like correct.

    So strange for this.

    Please help me.

    Luong Le

    1. Hi Luong,

      Today i did merge a pull request. Commit log can be found here: https://github.com/abhinavsingh/JAXL/commit/a29bffde52c253a1602fd7ee3f49090250f4733e
      And what this merge was about can be found here: https://github.com/abhinavsingh/JAXL/pull/1

      What PHP version are you upon?
      Does reverting back to previous version helps?
      Are you sure facebook isn’t blocking it in any ways, mostly by looking at XMPPSend and XMPPGet logs inside jaxl.log?

  19. Brad

    Is X-FACEBOOK-PLATFORM authentication still working for anyone who has created a new app id/key in the last few days? I’m receiving an authentication failure over XMPP.

  20. Jason Serafin

    Get [[XMPP]] Unable to open socket to the jabber host.


    ‘secret’ => ‘secret’,
    ‘cookie’ => true, // enable optional cookie support

    $session = $facebook->getSession();

    $me = null;
    // Session based API call.
    if ($session) {
    try {
    $uid = $facebook->getUser();
    $me = $facebook->api(‘/me’);
    } catch (FacebookApiException $e) {


    $jaxl = new JAXL( array(
    ‘pass’=>”, // Not required, we will use user session key instead

    ‘JAXL0115’, // Entity Capabilities
    ‘JAXL0092’, // Software Version
    ‘JAXL0199’, // XMPP Ping
    ‘JAXL0203’, // Delayed Delivery
    ‘JAXL0202’ // Entity Time

    function postAuth($payload, $jaxl) {
    $jaxl->sendMessage(‘[email protected]’, ‘Hello World’);

    function doAuth($mechanism) {
    global $jaxl;

    function getFacebookKey(){
    return array(

    // Register callback on required hooks
    $jaxl->addPlugin(‘jaxl_get_auth_mech’, ‘doAuth’);
    $jaxl->addPlugin(‘jaxl_get_facebook_key’, ‘getFacebookKey’);
    $jaxl->addPlugin(‘jaxl_post_auth’, ‘postAuth’);
    // Fire start Jaxl core


  21. Vlad

    I have a big problem, very very frustrating.

    I keep getting this error when I try to run the example from above:
    Fatal error: Call to undefined function jaxl_require() in /usr/local/lib/php/jaxl/core/jaxl.class.php on line 41

    I installed the Jaxl on my linux dedicated several times… but I stilll get this error.

    Can anyone help?


  22. Maize

    Hi Abhinav,

    i have read through your posts about xmpp and connection to facebook with big interest.

    Unfortunately i always get the

    error. The new Jaxl-Version you just uploaded and the one u already linked in the comments here do not work for me.

    They also donot the “build.sh” anymore which i would use to resetup my JAXL completely.

    Is there any way to debug the Facebook denial more or debug why my jaxl isn’t running on newest version? I do “jaxl myfile.php” and nothing happens. Not even an error.

    Thanks in advance.


  23. Ahmed Aly

    Thanks for your contribution..
    But I still need to know.. does the x-facebook authentication mechanism really work?

    Waiting for your answer urgently, and thanks.

  24. JMP


    I am using the latest branch from http://github.com/abhinavsingh/JAXL … but I have a problem.

    First of all there is no doAuth function in the echobot file, so how do I update it? Also, do I need to add the doAuth as a plugin?

    All I get at the moment when trying is:

    [1:97963:0] 2011-03-20 12:50:55 – [[XMPP]]
    Socket opened to the jabber host chat.facebook.com:5222 …

    And it stays stuck on that.

    I am using $arg[1] for the user, which equals my user id as: “-10299288”

    The session is $arg[2] which is my session_key Facebook returns when allowing the app with xmmp_login permissions.

    Any help?

    1. Hi JMP,

      There is a 'authType'=>'PLAIN' parameter passed to JAXL constructor. Which automatically chooses PLAIN authentication mechanism if available.
      You should change that to X-FACEBOOK-PLATFORM and then also implement required callback using JAXLPlugin::add('jaxl_get_facebook_key', array($echobot, 'getFacebookKey')); .

      Also i recommend users to download and use v 2.1.2-rc1 from google code download tab.

  25. JMP

    Thanks Abhinav,

    One more question. The above works, but it returns:

    [[XMPPGet]] Unable to complete SASL Auth, see logs for detail…

    I’ve added a break point and a log to the code, and Facebook is returning “not-authorized”.

    So, my question/s are.

    1) How should the username be formatted?
    2) Is the secret the app secret or the session secret?
    3) Is the session the session_key or the access_token (I know some people use them interchangeably).

    I am running from my computer, but I have set up my IP with Facebook as the url for the application. That shouldnt make a difference though right?

    Any response to the above questions, or advice, would be appreciated. I do plan on documenting this in a video for users at a later date.


  26. Ahmed Aly

    Hi and thanks for your reply..
    This is all I get when I try to use the library:
    [[JAXL]] No callbacks for shutdown [1:30205:0] 2011-03-20 21:15:48 – [[JAXL]] Calling JAXL0115 method getCaps [1:30205:0] 2011-03-20 21:15:48 – [[JAXLPlugin]] Executing hook jaxl_get_id for uid 1 [1:30205:0] 2011-03-20 21:15:48 – [[JAXL]] Shutting down …

    it seems like it does not connect.. so I need to know what should I call to connect to the server?

  27. Construct0r

    hi, i have a problem i can’t solve for hours…
    there is a problem in connection. Here is log:
    Socket opened to the jabber host chat.facebook.com:5222 …
    Performing Auth type: X-FACEBOOK-PLATFORM
    and then, fail:
    [1:3937:0] 2011-03-21 04:14:03 – [[XMPPGet]] 4096

    [1:3937:0] 2011-03-21 04:14:03 – [[XMPPGet]] Unable to complete SASL Auth, see logs for detail…

    i tested everything. I think it’s problem in $session[‘session_key’], because it’s empty.
    I have $session array, and it have sig, access_token, expire and uid, but there is no session_key.
    There is xmpp_login in permission list. I downloaded newest facebook.php (facebook api).
    I use edited version of your test app (sendMessage.php), I edited it for use with facebook.

    If you know what can be problem, please help!

    Thank you.

  28. Donny

    Hi Abhinav, great work on this frame work thanks so much. Do you know if its still possible to see what facebook users are active over XMPP. When I fetch the roster it appears they payload contains no online presence data? Best Regards, Donny

  29. Construct0r

    Ahmed, ofcourse. Look into it, and if you find error, please let me know.

    $session = $facebook->getSession();

    $jaxl = new JAXL(array(

    echo “$session[session_key]“;
    function getFacebookKey() {
    return array(
    $f_setAppSecret, // Your application secret key
    $f_setAppApi, // Your application api key
    $session[‘session_key’] // Connecting user session key

    // Post successful auth send desired message
    function postAuth($payload, $jaxl) {
    $jaxl->sendMessage(‘[email protected]’, ‘Hello World’);


    // Register callback on required hooks

    $jaxl->addPlugin(‘jaxl_get_facebook_key’, ‘getFacebookKey’);
    $jaxl->addPlugin(‘jaxl_post_auth’, ‘postAuth’);
    // Fire start Jaxl core

    above this code is part with includes i need, code for permission request for application, app connection with facebook, etc.
    Theoretically, this code should work, but i really don’t know why. I think it is because there is no session_key in $session array (which you get with $session = $facebook->getSession();

    Maybe facebook disabled it for some reason? Has anybody here application which works with chat at the moment? is it about me or facebook?

    And, if i remove ‘mode’=>’cli’, from code, there is no logs or anything. Just like script doesnt execute…
    Thank you!

  30. Matt

    Can you tell me how I can send a message in facebook chat to another user?

    This is my code:
    function postAuth($payload, $jaxl) {

    $jaxl->sendMessage(‘[email protected]’, ‘hi’);

    but it doesn’t work.
    Do you have any idea on what I’m doing wrong?

    2011-03-21 13:08:24 – [[XMPP]]
    Socket opened to the jabber host chat.facebook.com:5222 …

    [1:16900:0] 2011-03-21 13:08:24 – [[XMPPSend]] Performing Auth type: X-FACEBOOK-PLATFORM

    [1:16900:1] 2011-03-21 13:08:25 – [[XMPPGet]] Auth completed…

    [1:16900:1] 2011-03-21 13:08:25 – [[JAXL]] Shutting down …

  31. Construct0r

    Hi Abhinav,
    I made it! It connects and sends message correct! Thank you for awesome work.

    Now, I just need help about how to get list of online users. I have $session array and session_key. Please help:)

    Thank you, again!

  32. Ahmed Aly

    Thank you so much.

    I replaced some of my code with yours, and started responding, but it still does not really work..
    here is what I got:
    [[JAXL]] OpenSSL extension is loaded. [1:31923:0] 2011-03-21 18:35:54 – [[XMPP]] Unable to open socket to the jabber host chat.facebook.com:5222 …

    should I try it with another IP address?

  33. El33

    Abhinav, hi.
    I succefully made application which connects to facebook and sends chat message to choosen friend. It works great, but there is a problem. Most of users (90%) said that their antivirus reports application as virus (xmpp virus)!? what!? Why is that? Application does not have anything illegal or special, just simple option to send message.

    1. Anti virus doesn’t know anything about the library or sendMessage() method. Anti-virus is most probably detecting the incoming message as virus because of content or links inside it. I am not sure, but no reason why Jaxl library will have to do anything with such messages…..

  34. Hafiz

    Hi Abhinav…

    I like your code here, but I think you must create new post to explain Step By Step about JAXL + X-FACEBOOK-PLATFORM. Many user want to know it, but I think something missing (explanation) here. And this code too :
    $session = $facebook->getSession();

    $jaxl = new JAXL(array(

    echo “$session[session_key]”;
    function getFacebookKey() {
    return array(
    $f_setAppSecret, // Your application secret key
    $f_setAppApi, // Your application api key
    $session[‘session_key’] // Connecting user session key

    // Post successful auth send desired message
    function postAuth($payload, $jaxl) {
    $jaxl->sendMessage(‘[email protected]’, ‘Hello World’);


    // Register callback on required hooks

    $jaxl->addPlugin(‘jaxl_get_facebook_key’, ‘getFacebookKey’);
    $jaxl->addPlugin(‘jaxl_post_auth’, ‘postAuth’);
    // Fire start Jaxl core

    I test the fresh code jaxl/app/sendMessage.php and just change Username & Password at that files, but still got error :

    Warning: touch() [function.touch]: Unable to create file /var/log/jaxl.log because Permission denied…

    Fatal error: Uncaught exception ‘JAXLException’ with message ‘Log file /var/log/jaxl.log doesn’t exists’

  35. Hafiz

    Hi Ahmed, can you share your experience here? I got nothing 🙁

    Hope this post not called spam here :

    Hi Abhinav, already test your v2.1.2… Is this just can run on localhost? Can’t run on web hosting? I’m using PHP5 too and test your code more than 5 hours just now and nothing I got for possible run FB Chat… 🙁

    I think your guide not complete or not update. Hope you can make a new post and telling how to & step by step about new version…

    I already test your old version too, and seriously I got nothing here… And I don’t know this is the truth code can use FB Chat or not… Still try and try but now very stuck just focus on your code…

  36. Don

    Hi Abhinav,

    I’ve already contacted you on Facebook Private message, but hope you don’t mind that I post my issue here too… 🙂

    My PHP Version: 5.2.9
    My System: CENTOS 5.5 i686 virtuozzo on cpanel

    I’m using the latest JAXL downloaded from github.com

    My problem: I’ve got this while outputting $jaxl:

    [xml] => XML Object
    [valid] =>

    Seems the XML object is still empty (I’ve heard that someone had this problem too and you’ve made a patch for it to work on CENTOS too, but despite of that update i’ve still got empty XML object)…

    I appreciate your work on JAXL, its really a nice tool!

    You can contact me on facebook (if you see my messages) or post an asnwer here.

    Thanks in advance!

  37. Martin

    This is too short and 100% impossible for a newbie to figure out.

    Next time Abhinav, make the FULL tutorial and post it, or don’t post it at all.

    This does nothing…

    Good luck!

  38. El33

    I can get list of online friends with getRoster…but it’s kinda slow-because it returns list of all friends (first those who are online, and then offline users). Is there any way to make it return only online users? I saw it uses $payload = ”; … any modification?

    1. Hi El33, This is something that you need to handle inside your app itself. You have $jaxl->roster which have a list of ur buddy and whether they r online or offline information. In case they r online, it also provide you with resource info associated with the user.

  39. Shaun

    Hi, I’m attempting to integrate web-based facebook chat into my application and I was having trouble connecting to chat.facebook.com
    [[XMPP]] Unable to open socket to the jabber host

    I read many of the above comments and decided to check to see if port 5222 was blocked on my server…it was! 🙁

    I’m guessing there’s no way around this, so I’m wondering if you guys who are successfully up and running would have any good suggestions on web hosts that don’t block 5222? (And under $10…I don’t need VPS or anything fancy like that)

    I hope you don’t mind the mildly unrelated question, but jaxl will be extremely useful to my applications and I’d love to get it up and running!

    Thanks in advance!

  40. I was getting function jaxl_require not defined errors too, I downloaded the latest build from code.google.com and I am no longer getting this error but I am getting deprecated errors:

    ( ! ) Deprecated: Call-time pass-by-reference has been deprecated in C:wampwwwJAXLxmppxmpp.class.php on line 300
    Call Stack
    # Time Memory Function Location
    1 0.0008 696584 {main}( ) ..preFetchXMPP.php:0
    2 0.0028 1037464 require_once( ‘C:wampwwwJAXLcorejaxl.class.php’ ) ..preFetchXMPP.php:19
    3 0.0029 1039400 jaxl_require( ) ..jaxl.class.php:108

  41. Pingback: facebook chat bot

  42. stella

    Hi Abhinav,

    I have a question, not about jaxl API, but about how the authentication is done in detail (the message flow between the xmpp client and facebook chat server).

    I guess the authentication start with a msg from my app to facebook:

    What is the ClientID? How to get the client ID? is it my facebook userid or something else?

    Thanks a lot for your kind help!

  43. alex

    Abhinav Singh, thanks for this awesome work.

    For those who get the error “Unable to complete SASL Auth” it might be related to the old Facebook authentication. Now OAuth2.0 returns the access_token but X-FACEBOOK-PLATFORM needs a session_key.

    The solution is in the access_token. An access_token is form as follow:

    which is:

    To use X-FACEBOOK-PLATFORM, you can extract the session_key from the
    access_token and authenticate the user.


  44. Cadell

    hello, firstly excellent work however long it took me to finally get it running, secondly i am trying to run this code remotely on a free web host by simply running the script by browsing to the page. this produces no errors but it doesn’t say it has succeeded either. also my jaxl log is empty. is something wrong? and alex i wish i saw your post about an hour ago.

  45. Cadell


    if anyone wants to know how to get this working on a regular webhost with prefetch.xmpp.php instead of the console let me know, free of charge ofcourse unlike some other people i’ve seen.

  46. stella


    I am writing a web app, where I want the user to be able to:
    1) log in to Facebook
    2) have FB chat function (load facebook friends list, updated with friends online status information, be able to send/receive chat msg)

    My first attempt was using XHR to call an auth.php to do the x-facebook-platform authentication, resource binding, etc via a socket. It was successful. However,I would like to keep the socket alive and let other php script (triggered by other XHR when the user wants to send a msg) to use that socket. I am stuck there. I found no solution to let several php share one socket.

    Therefore, I am investigating how to use JAXL libary. Does jaxl library server my purpose? Does it allow my webpage communicate with facebook chat server directly, to do the authentication, sending/receiving msg, presence update?

    Thanks for your kind help!

  47. Mohit

    Hi Abhniav

    Thanks for such a great library.

    I am able to authenticate user with x-facebook-platform and send a message to other users. But I am facing issue while I add plugin for get message :

    $jaxl->addPlugin(‘jaxl_get_message’, array($echobot, ‘getMessage’));

    if I use $jaxl->shutdown() at the end, getMessage stops working.
    I understand that $jaxl must be running, but if I do not write $jaxl->shutdown(), my script hangs and doesnot allow me to surf other pages on my site.

    I am running script from browser.

    How can I handle such situation..?

    Please help me on this issue.

  48. Cadell

    Dev i am making the tutorial at the moment i just need to make this work ona remote server instead of my local apache one. does anyone know a free webhost that supports stream_socket or an alternative to stream_socket?

  49. Mark

    I am able to auth successfully. and also able to send message in postAuth.

    My query is : Can we use “sendMessage” function in postAuth method only ?

    How can we use “sendMessage” at our desired action.?

  50. Berk

    Hi Abhinav,
    I am implementing a facebook chat,
    Do I really need bosh chat. I have problems using bosh server.

    What does boshhost, host and domain represents in jaxl settings?

  51. Hi Abhinav
    i have a quick question. what function needs to be complete before i can populate an online and offline users list. at the moment i am calling back after “jaxl_post_roster_update” but this appears to cut off the end response of the roster list on a list of 500 people (the data sent doesn’t even have a closing tag as if the last block is missing). is it meant to take about 40 secs?

  52. Ivan

    Hello, Abhinav.

    I hope, its suitable place to ask question about your great library)

    Recently, facebook updated theirs authentication mechanism, and now library is unable to sucesfully finish authentification, using ‘session_key’. Developers have to use ‘auth_token’ instead.

    My question is, do you planning to make any updates of library? Or may do you know somebody, who already dealt with same problem, and have solution for it?

    With best regards, Ivan

    1. Hi Ivan, Indeed your are the first one to report this via a blog comment or via group post. Few developers already reported about this via chat to me, probably about a week ago. I guess that was when facebook changed their authentication mechanism requirements. I plan to update the library and come out with various patches submitted by various other developers. However u can until then simply go and use the library by what you have found out as the code breaking change. I will mostly update the library by monday with new changes required for successful facebook auth.

  53. George Rubin

    JAXL Patch:

    xmpp.auth.php line 62, change:

    list($secret, $decoded[‘api_key’], $decoded[‘access_token’]) = JAXLPlugin::execute(‘jaxl_get_facebook_key’, false, $jaxl);

    $decoded[‘call_id’] = time();
    $decoded[‘v’] = ‘1.0’;

    $base_string = ”;
    foreach(array(‘api_key’, ‘call_id’, ‘method’, ‘nonce’, ‘access_token’, ‘v’) as $key) {
    if(isset($decoded[$key])) {
    $response[$key] = $decoded[$key];
    $base_string .= $key.’=’.$decoded[$key];


  54. Jason

    @George Rubin, @Ivan & @Abhinav,

    I am completely new to XMPP/BOSH/Chat, so bear with me.

    I am trying to use PHP to talk with Facebook Chat API and this library seemed promising.

    Due to the architecture of my clients mobile platform, I can’t use Javascript or the command line. So I need to use PHP’s GET & POST var’s.

    I am confused about two things:

    1) how to establish a connection using Jaxl to Facebook Chat using OAuth/X-FACEBOOK-PLATFORM SASL authentication mechanism.
    2) once I’ve established a connection, and send a test message to a Facebook Chat user, how can I get Jaxl to display the chat response?

    I hope you can help shed some light on this for me!

    Cheers, Jason.

  55. Bhoopesh

    Hi Abhinav,

    I am trying to implement Facebook chat on website using Jaxl.

    i have configured jaxl.ini, echobot.php as per instructions given in http://abhinavsingh.com/blog/2010/08/facebook-chat-connect-with-x-facebook-platform-using-jaxl-2-0/

    But i am getting a Fatal Error as : Call to undefined function jaxl_require() in /home/helloh5/public_html/dev/fbchat2/core/jaxl.class.php on line 41

    i was not able to find function jaxl_require() in complete Jaxl Project.

    Please help me.

  56. Lina Clark

    Hi abhinav,
    I am trying to implement XMPP client for X-facebook-platform where i need not give my login credentials. My appId and access token can fulfill the purpose. I am able to connect successfully but afterwards i don’t know how to login to facebook chat so that i can fetch the friend list of the user.
    Can ya help..


  57. Eyasu

    I had to update xmpp.auth.php in jaxl/xmpp with the following changes.

    Replace session_key with access_token

    The API parameters have changed with OAuth 2.0

  58. Pingback: How to perform X-FACEBOOK-PLATFORM and Google Talk X-OAUTH2 XMPP authentication with PHP Jaxl library | Abhi's Weblog

Comments are closed.