Facebook Connect for Mobile Web
From Facebook Developer Wiki
Contents |
Facebook Connect for Mobile Web
Facebook Connect for Mobile Web is a PHP library that lets you connect your users' Facebook accounts with your mobile website or application. The code provides:
- An authentication / login mechanism.
- User session data.
- The ability to call methods from the Facebook Platform API and prompt for extended permissions.
- Publishing directly to the Facebook Stream
You need to use these Facebook Connect for Mobile Web buttons for Connecting users and logging them out.
You should familiarize yourself with the Platform Principles and Policies.
Getting Started with Facebook Connect for Mobile Web
- Set up your application and get an API key.
- Configure the following applications settings:
- On the Basic tab: Specify an Application Name, Description, Icon, and Logo.
- On the Canvas tab: Specify Canvas Callback URL and Post-Authorize Redirect URL. These are the URLs that Facebook will redirect the user to after authentication/posting.
- On the Connect tab: Specify a Connect URL, the URL to your Facebook Connect site. Also specify a Facebook Connect Logo, which isn't used on the Mobile Web application, but will be used on your website.
- Click Save Changes to ensure that your configuration settings are saved.
- Download Facebook Connect for Mobile Web libraries and sample code.
- Unzip the sample code and library on your server.
- Create the MySQL databases and set up the configuration as per lib/config.php
Using Connect for Mobile Web in Your Own Projects
- Download Facebook Connect for Mobile Web libraries, then unzip the archive.
- Copy the facebook-platform/php folder into your project's library folder - rename it facebook-client.
- Include the Connect files in your code:include_once MAIN_PATH.'/facebook-client/facebook.php';
include_once MAIN_PATH.'/facebook-client/facebook_mobile.php';
You are now ready to start using it.
Logging Users In, Getting Sessions, and Prompting for Extended Permissions
For more information, see Authentication and Authorization for Facebook for Mobile Applications.
You use standard Facebook Connect login buttons to assist in logging in your users. See Facebook Connect Login Buttons for details.
Publishing to a User's Stream on Facebook
In order to publish to the user's stream, you need to prompt the user for the publish_stream extended permission.
Once the user grants you the permission, direct the user to http://www.facebook.com/connect/prompt_feed.php and include the following parameters:
- api_key: The API key you received from Facebook earlier.
- session_key: The session key returned from auth.getSession.
- attachment: This is the attachment for the story, which is formatted exactly as an Open Stream API attachment.
- preview: Set to 1 to display a Feed form. If set to 0, directly publish without a Feed form (Note: You need the
publish_streamextended permission to publish to a user's Stream directly). - user_message_prompt: The text for the title of the Feed form.
- callback: The URL to direct the user after publishing the story.
- cancel: The URL to direct the user who cancels the post.
- action_links: The array of action links to include in the post.
- display: Set this to wap.
For example, here's the Feed form prompt from the Facebook Connect for Mobile Web sample application:
