New

Just launched: Vueblocks, a brand-new search engine for Vue packages! Explore Vueblocks →

fbf/laravel-mobile-facebook-app

A Laravel Filter for Facebook Page Tab Apps that need to work on mobile too.
32 3
Install
composer require fbf/laravel-mobile-facebook-app
Latest Version:v0.1.0
PHP:>=5.3.0
Laravel:4
License:MIT
Last Updated:Jan 17, 2014
Links: GitHub  ·  Packagist
Maintainer: neilcrookes

Laravel Mobile Facebook App

A Laravel Filter for Facebook Page Tab Apps that need to work on mobile too.

Concept

For all routes that you apply the filter too, it checks to see if the user is not on mobile and is not the facebook bot and hasn't already been redirected to Facebook (prevents endless redirection once inside the iFrame), then redirects the user to the tab app on your Facebook Page, on the page in your app that the user was trying to access originally.

However, if the user is on mobile (or it's the Facebook bot that gets open graph data), don't do the redirect and just show them the page they are after.

All links to your app that get shared on social networks and other websites or apps should be to your domain, not the Facebook Tab App URL.

I.e.

http://myfacebookapp.com/path/to/page?query=string&shared=true

not

http://www.facebook.com/pages/mypage?sk_app=123456789&app_data=...

Note the shared=true query string param in the above URL - this is required in all links to your app that are shared on social networks or included on other websites. It's needed in case this is the second or third etc time that the user visited your app not on a mobile device and they already have a valid session. It's required because we set a flag in the session to remember that the user has been redirected to facebook, so when the app is loaded again inside the iFrame the user is not redirected again, resulting in an infinite loop. However, if this is not the first time a user follows a link to your app, and they already have a session, this shared=true query string parameter removes this flag from the session before checking whether they have already been redirected, so that they get redirected again. Get that? No? Me neither.

Installation

Add the following to you composer.json file

"fbf/laravel-mobile-facebook-app": "dev-master"

Run

composer update

Add the following to app/config/app.php

'Fbf\LaravelMobileFacebookApp\LaravelMobileFacebookAppServiceProvider'

Publish the config from thomaswelton/laravel-facebook to app/config/packages (this library is used to decode the signed request and to get the tab app URL for your app)

php artisan config:publish thomaswelton/laravel-facebook

Add your app id and secret to the published config file

Usage

Register and apply the filter, add the following to app/routes.php

Route::filter('facebook', 'LaravelMobileFacebookAppFilter');
Route::when('my/routes/*', 'facebook');

Related Packages

mjarestad/filtry

Filter and sanitize input data in Laravel 4/5 or as a standalone package.

231,117 13
xmhafiz/fb-page-feed

Simple wrapper class to get any Facebook Page posts

152,186 66
daveismyname/laravel-filters

Save and reuse query string based filters

63,590 9
coderscantina/laravel-filter

A filter object for Laravel/Eloquent models based on laracasts approach.

9,534 2
bzarzuela/modelfilter

Utility Class for Laravel 5 to assist in easily filtering paginated results.

1,672 5

Version History

Version Released PHP Laravel License
v0.1.0 >=5.3.0 4.0.x MIT