PHPackages                             insolis/facebook-service-provider - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [HTTP &amp; Networking](/categories/http)
4. /
5. insolis/facebook-service-provider

ActiveLibrary[HTTP &amp; Networking](/categories/http)

insolis/facebook-service-provider
=================================

Lightweight silex service to ease communication with facebook

v1.3(12y ago)02651[1 issues](https://github.com/insolis/facebook-service-provider/issues)MITPHP

Since Aug 27Pushed 12y ago2 watchersCompare

[ Source](https://github.com/insolis/facebook-service-provider)[ Packagist](https://packagist.org/packages/insolis/facebook-service-provider)[ RSS](/packages/insolis-facebook-service-provider/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (1)Versions (7)Used By (0)

facebook-service-provider
=========================

[](#facebook-service-provider)

It's a lightweight [Silex](http://silex.sensiolabs.org/) service to help creating Facebook applications.

Dependencies
------------

[](#dependencies)

It depends on two other providers:

- [Session](http://silex.sensiolabs.org/doc/providers/session.html)
- [URL Generator](http://silex.sensiolabs.org/doc/providers/url_generator.html)

It also uses the current request.

Configuration
-------------

[](#configuration)

It's done via the `fb.options` key. It's supposed to be an array with the following keys:

- `app_id`: your application's id
- `app_secret`: your application's secret token
- `permissions`: an array with the needed permissions
- `redirect_route`: name of the route which is responsible for handling new user authentications

Usage
-----

[](#usage)

The service sets the following session keys:

- `fb.access_token`: the access token you can use to make requests against the graph API
- `fb.page_liked`: whether the current page is liked or not

A `before()` middleware is registered to be run before yours. It handles two cases:

- it's a post request and we have a `signed_request` parameter: decoding is done automatically and set among the post values with the `fb.data` key
- it's a request for the aforementioned redirect route, and we have a `code` query parameter: fetching a token, then the user details is done automatically, set among the post values with the `fb.data` key

In both cases the event `fb.user_info` is dispatched, with the user data as the subject.

Events
------

[](#events)

- `fb.user_info` when getting user data from facebook
- `fb.like` when the user just liked the page
- `fb.unlike` when the user just unliked the page

Samples
-------

[](#samples)

A sample application-level `before` middleware to log a user in automatically:

```
