Download the PHP package league/oauth2-facebook without Composer
On this page you can find all versions of the php package league/oauth2-facebook. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download league/oauth2-facebook
More information about league/oauth2-facebook
Files in league/oauth2-facebook
Package oauth2-facebook
Short Description Facebook OAuth 2.0 Client Provider for The PHP League OAuth2-Client
License MIT
Informations about the package oauth2-facebook
Facebook Provider for OAuth 2.0 Client
This package provides Facebook OAuth 2.0 support for the PHP League's OAuth 2.0 Client.
This package is compliant with PSR-1, PSR-2, PSR-4, and PSR-7. If you notice compliance oversights, please send a patch via pull request.
Requirements
The following versions of PHP are supported.
- PHP 7.3
- PHP 7.4
- PHP 8.0
Installation
Add the following to your composer.json
file.
Usage
Authorization Code Flow
The FacebookUser Entity
When using the getResourceOwner()
method to obtain the user node, it will be returned as a FacebookUser
entity.
You can also get all the data from the User node as a plain-old PHP array with toArray()
.
Graph API Version
The graphApiVersion
option is required. If it is not set, an \InvalidArgumentException
will be thrown.
Each version of the Graph API has breaking changes from one version to the next. This package no longer supports a fallback to a default Graph version since your app might break when the fallback Graph version is updated.
See the Graph API version schedule for more info.
Beta Tier
Facebook has a beta tier that contains the latest deployments before they are rolled out to production. To enable the beta tier, set the enableBetaTier
option to true
.
Refreshing a Token
Facebook does not support refreshing tokens. In order to get a new "refreshed" token, you must send the user through the login-with-Facebook process again.
From the Facebook documentation:
Once [the access tokens] expire, your app must send the user through the login flow again to generate a new short-lived token.
The following code will throw a League\OAuth2\Client\Provider\Exception\FacebookProviderException
.
Long-lived Access Tokens
Facebook will allow you to extend the lifetime of an access token by exchanging a short-lives access token with a long-lived access token.
Once you obtain a short-lived (default) access token, you can exchange it for a long-lived one.
Getting Additional Data
Once you've obtained a user access token you can make additional requests to the Graph API using your favorite HTTP client to send the requests. For this example, we'll just use PHP's built-in file_get_contents()
as our HTTP client to grab 5 events from the the authenticated user.
See more about:
If you need to make even more complex queries to the Graph API to get lots of data back with just one request, check out the Facebook Query Builder.
Testing
Contributing
Please see CONTRIBUTING for details.
Credits
License
The MIT License (MIT). Please see License File for more information.