Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,22 @@ on:
pull_request:
branches:
- master
- develop
push:
branches:
- master
jobs:
test:
runs-on: ubuntu-20.04
runs-on: ubuntu-24.04
strategy:
matrix:
php: [ '7.3', '7.4', '8.0', '8.1', '8.2', '8.3' ]
php: [ '8.1', '8.2', '8.3', '8.4' ]
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- run: mkdir -p build/logs
- name: Test PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{matrix.php}}
- run: composer install
- run: php vendor/bin/phpunit --exclude-group integration
- run: php vendor/bin/phpunit
24 changes: 0 additions & 24 deletions .travis.yml

This file was deleted.

421 changes: 258 additions & 163 deletions CHANGELOG.md

Large diffs are not rendered by default.

55 changes: 28 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
[![Build Status](https://github.com/nickdnk/php-graph-sdk/actions/workflows/test.yml/badge.svg?branch=master)](https://github.com/nickdnk/php-graph-sdk/actions/workflows/test.yml)
[![Latest Stable Version](http://img.shields.io/badge/Latest%20Stable-7.0.1-blue.svg)](https://packagist.org/packages/nickdnk/graph-sdk)
[![Downloads](https://img.shields.io/packagist/dt/nickdnk/graph-sdk?label=Downloads)](https://packagist.org/packages/nickdnk/graph-sdk)
### This is an unofficial version of Facebook's PHP SDK designed for PHP 7/8+. It is being maintained and tested against the newest PHP versions. You can use this in place of version `5.x` of Facebook's deprecated `facebook/graph-sdk` package.
### This is an unofficial version of Facebook's PHP SDK designed for PHP 8+. It is being maintained and tested against the newest PHP versions. You can use this in place of version `5.x` of Facebook's deprecated `facebook/graph-sdk` package.

## PHP 7.3 is required.
### PHP 8.1 is required.

This repository contains the open source PHP SDK that allows you to access the Facebook Platform from your PHP app.

Expand All @@ -20,7 +20,7 @@ composer require nickdnk/graph-sdk
By default, the request will be made via a `Facebook\HttpClients\FacebookHttpClientInterface`. The default
implementation depends on the available PHP extension/packages. In order of priority:

1. Package `guzzlehttp/guzzle` (version 6 or 7): `Facebook\HttpClients\FacebookGuzzleHttpClient`
1. Package `guzzlehttp/guzzle` (v6 and v7 only): `Facebook\HttpClients\FacebookGuzzleHttpClient`
2. ext-curl: `Facebook\HttpClients\FacebookCurlHttpClient`
3. Fallback: `Facebook\HttpClients\FacebookStreamHttpClient`

Expand All @@ -29,12 +29,17 @@ implementation depends on the available PHP extension/packages. In order of prio
Simple GET example of a user's profile.

```php
require_once __DIR__ . '/vendor/autoload.php'; // change path as needed
require_once __DIR__ . '/vendor/autoload.php';

$fb = new \Facebook\Facebook([
use Facebook\Facebook;
use Facebook\GraphNodes\GraphUser;
use Facebook\Exceptions\FacebookResponseException;
use Facebook\Exceptions\FacebookSDKException;

$fb = new Facebook([
'app_id' => '{app-id}',
'app_secret' => '{app-secret}',
'default_graph_version' => 'v2.10',
'default_graph_version' => 'v20.0',
//'default_access_token' => '{access-token}', // optional
]);

Expand All @@ -45,45 +50,41 @@ $fb = new \Facebook\Facebook([
// $helper = $fb->getPageTabHelper();

try {
// Get the \Facebook\GraphNodes\GraphUser object for the current user.

// If you provided a 'default_access_token', the '{access-token}' is optional.
$response = $fb->get('/me', '{access-token}');
} catch(\Facebook\Exceptions\FacebookResponseException $e) {

// To decode the response to a PHP class, provide the class of the root node in the response. You will have to match
// this manually based on the endpoint you requested. Please do open a pull request if you want to add more types.

/** @var GraphUser $me */
$me = $response->getGraphNode(GraphUser::class);
echo 'Logged in as ' . $me->getName() . PHP_EOL;
echo 'User email is ' . $me->getEmail() . PHP_EOL;

} catch (FacebookResponseException $e) {

// When Graph returns an error
echo 'Graph returned an error: ' . $e->getMessage();
exit;
} catch(\Facebook\Exceptions\FacebookSDKException $e) {

} catch (FacebookSDKException $e) {

// When validation fails or other local issues
echo 'Facebook SDK returned an error: ' . $e->getMessage();
exit;

}

$me = $response->getGraphUser();
echo 'Logged in as ' . $me->getName();
```

Complete documentation, installation instructions, and examples are available [here](docs/).

## Tests

1. [Composer](https://getcomposer.org/) is a prerequisite for running the tests. Install composer globally, then
run `composer install` to install required files.
2. Create a test app on [Facebook Developers](https://developers.facebook.com), then
create `tests/FacebookTestCredentials.php` from `tests/FacebookTestCredentials.php.dist` and edit it to add your
credentials.
3. The tests can be executed by running this command from the root directory:
2. The tests can be executed by running this command from the root directory:

```bash
$ ./vendor/bin/phpunit
```

By default, the tests will send live HTTP requests to the Graph API. If you are without an internet connection you can
skip these tests by excluding the `integration` group.

```bash
$ ./vendor/bin/phpunit --exclude-group integration
```

## License

Please see the [license file](https://github.com/facebook/php-graph-sdk/blob/master/LICENSE) for more information.
10 changes: 5 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "nickdnk/graph-sdk",
"description": "Facebook SDK for PHP compatible with PHP8",
"description": "Facebook SDK for PHP 8+",
"keywords": ["facebook", "sdk"],
"type": "library",
"homepage": "https://github.com/nickdnk/php-graph-sdk",
Expand All @@ -12,12 +12,12 @@
}
],
"require": {
"php": "^7.3 || ^8.0"
"php": "^8.1"
},
"require-dev": {
"phpunit/phpunit": "~9.5",
"mockery/mockery": "~1.5.1",
"guzzlehttp/guzzle": "^6.5.0 | ^7.5.0"
"phpunit/phpunit": "^9.5",
"mockery/mockery": "^1.6.12",
"guzzlehttp/guzzle": "^7.9.2"
},
"conflict": {
"guzzlehttp/guzzle": "<6.0"
Expand Down
34 changes: 0 additions & 34 deletions docs/README.md

This file was deleted.

41 changes: 0 additions & 41 deletions docs/examples/access_token_from_canvas.md

This file was deleted.

86 changes: 0 additions & 86 deletions docs/examples/access_token_from_javascript.md

This file was deleted.

47 changes: 0 additions & 47 deletions docs/examples/access_token_from_page_tab.md

This file was deleted.

Loading