robbiehanson edited this page Nov 18, 2011 · 1 revision

How-to implement Facebook Chat


Facebook chat client users can authenticate with one of two authentication mechanisms: X-FACEBOOK-PLATFORM (Facebook Platform) and DIGEST-MD5 (username/password). Facebook recommends the use of the X-FACEBOOK-PLATFORM mechanism to connect to Facebook Chat whenever possible, because it provides a better user experience using simple Facebook Platform authentication. See Configuring Chat Authentication for a detailed comparison of features and limitations of each method.

This page explains how to use X-FACEBOOK-PLATFORM SASL authentication.

Facebook app settings

NOTE: As of the October 1st, 2011 Facebook OAuth changes, configuring Facebook Chat is very simple. All you need is your Facebook App ID.

If you want to enable more than what Facebook calls xmpp_login permissions, you may need to configure additional Facebook app settings. Those additional settings are beyond the scope of this document, but you can post configuration questions to the XMPPFramework Google group.



NOTE: As of October 1st, 2011, the facebook-ios-sdk is available as a git submodule of the XMPPFramework project. The customized fork we were previously recommending is no longer needed.

After using git to download the XMPP Framework, use the following command to checkout the facebook-ios-sdk:

git submodule update --init

The facebook-ios-sdk is stored in Vendor/facebook-ios-sdk. The FacebookTest sample app expects the Facebook files to be in this location.

Authenticate with Facebook

Authenticate normally with Facebook using the facebook-ios-sdk. The permissions array must contain xmpp_login for X-FACEBOOK-PLATFORM SASL authentication to work.

X-FACEBOOK-PLATFORM SASL authentication ONLY works over TLS connections, so make sure your code secures the connection first.

To see working sample code of how to authenticate with Facebook, look at the FacebookTest app. The FacebookTest app requests a Facebook access token (using SSO and the facebook-ios-sdk) and uses the access token to authenticate with Facebook over TLS using X-FACEBOOK-PLATFORM SASL.

The FacebookTest app is a build and run app, there is no need to configure a Facebook App Id first.

If everything is worked correctly, the app will display XMPP authenticated.