https://github.com/sohaibilyas/facebook-php-sdk
Easy to use PHP SDK to interact with Facebook API.
https://github.com/sohaibilyas/facebook-php-sdk
facebook-api facebook-graph-api facebook-marketing-api facebook-php-sdk
Last synced: about 1 month ago
JSON representation
Easy to use PHP SDK to interact with Facebook API.
- Host: GitHub
- URL: https://github.com/sohaibilyas/facebook-php-sdk
- Owner: sohaibilyas
- License: mit
- Created: 2020-04-25T20:20:29.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2024-09-21T00:52:30.000Z (over 1 year ago)
- Last Synced: 2025-10-08T23:28:17.386Z (3 months ago)
- Topics: facebook-api, facebook-graph-api, facebook-marketing-api, facebook-php-sdk
- Language: PHP
- Homepage:
- Size: 43 KB
- Stars: 8
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Facebook PHP SDK
Easy to use PHP SDK to interact with Facebook API.
## Installation
Use the composer to install.
```bash
composer require sohaibilyas/facebook-php-sdk
```
## Usage
```php
'app-id-here',
'app_secret' => 'app-secret-here',
'redirect_url' => 'https://sohaibilyas.com'
]);
$facebook->handleRedirect(function($user) {
// save access token to use it later e.g. session, database
$_SESSION['access_token'] = $user->access_token;
});
// checking if access token is saved otherwise show login with facebook url
if (isset($_SESSION['access_token'])) {
// setting default access token for all requests
$facebook->setAccessToken($_SESSION['access_token']);
// default response type e.g. object, json, array
$facebook->setResponseType('json');
// getting facebook user information
print_r($facebook->getAdAccounts());
} else {
echo $facebook->getLoginUrl(['email', 'ads_management', 'business_management', 'ads_read']);exit;
}
```
## License
[MIT](https://choosealicense.com/licenses/mit/)