This is a customised project creation process geared towards Facebook development.
It includes an installer that'll create a Facebook application, a tab module, and copy files with useful code to deal with access tokens and user authentication within Facebook.
The plugin also includes extensions to the web debug bar for profiling API calls.
To make API calls, rather than instantiating an instance of the Facebook SDK, use:
- Facebook SDK: https://github.com/facebook/facebook-php-sdk
Additional Plugin installed:
- sfMobilePlugin: https://github.com/HollerLondon/sfMobilePlugin (All apps need to have a mobile page - even if it's just a landing page directing them to the tab)
- sfDoctrineGuardPlugin: http://www.symfony-project.org/plugins/sfDoctrineGuardPlugin (For mobile auth / backend)
- sfGoogleAnalyticsPlugin: http://www.symfony-project.org/plugins/sfGoogleAnalyticsPlugin (For mobile / custom tracking)
NOTE: svn:externals included below.
Check out the project locally, assuming this was generated by Trac then it should have a folder structure and symfony installed in
Add the plugin to your
pluginsfolder (NOTE: the installer will take care of the rest)
Generate the project using the installer:
php lib/vendor/symfony/data/bin/symfony generate:project --installer=plugins/sfFacebookAppPlugin/data/installer.php PROJECTNAME
Create a Facebook app and fill in your Facebook app details in the frontend
app.yml, NOTE: If creating a Facebook tab make sure you use YOUR_URL/tab as the starting url
Then, in the action where you want to authorise the app with the user add:
if (false === $this->access_token && $this->signed_request) $this->redirect('@auth?signed_request='.$this->signed_request);
If you want to request additional permissions (not in the regular scope)
$additionalScope = 'email'; if (false === $this->access_token && $this->signed_request) $this->redirect(sprintf('@auth_scope?scope=%s&signed_request=%s', $additionalScope, $this->signed_request));
If you want to be able to interact with the tab whilst using Facebook as the page (the like button disappears), you need to disable the like gate for admins only:
prod: facebook: like_gate: enabled: true enabled_for_admin: false # disable for "use as page"
If you want to Google track the source of incoming tab links, you'll want to enable the tracking - Facebook tabs only. NOTE: You'll need to make sure when linking to a tab or doing any redirects you include the
?app_datawith the required source - e.g:
tracking: enabled: true prefix: source_ utm_campaign: CAMPAIGN utm_medium: MEDIUM
Install the extra plugins and vendors mentioned above
Enable plugin in ProjectConfiguration
And enable the module in the app's
enabled_modules: [ sfFacebookAppTab ]
Include the signed request filter in the app's
# insert your own filters here sfFacebookApp: class: sfFacebookSignedRequestFilter
config/autoload.ymlto include the Facebook SDK:
autoload: fb_sdk: name: facebook path: %SF_LIB_DIR%/vendor/facebook/src
Follow above from step 2. (NOTE that the installer does a lot of the groundwork for you - so have a look at the files in there)