Skip to content

Commit 63caaa2

Browse files
committed
Major update, see changelog
1 parent 78c565f commit 63caaa2

File tree

187 files changed

+3505
-7895
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

187 files changed

+3505
-7895
lines changed

.github/workflows/test.yml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,22 @@ on:
33
pull_request:
44
branches:
55
- master
6+
- develop
67
push:
8+
branches:
9+
- master
710
jobs:
811
test:
9-
runs-on: ubuntu-20.04
12+
runs-on: ubuntu-24.04
1013
strategy:
1114
matrix:
12-
php: [ '7.3', '7.4', '8.0', '8.1', '8.2', '8.3' ]
15+
php: [ '8.1', '8.2', '8.3', '8.4' ]
1316
steps:
14-
- uses: actions/checkout@v2
17+
- uses: actions/checkout@v4
1518
- run: mkdir -p build/logs
1619
- name: Test PHP
1720
uses: shivammathur/setup-php@v2
1821
with:
1922
php-version: ${{matrix.php}}
2023
- run: composer install
21-
- run: php vendor/bin/phpunit --exclude-group integration
24+
- run: php vendor/bin/phpunit

.travis.yml

Lines changed: 0 additions & 24 deletions
This file was deleted.

CHANGELOG.md

Lines changed: 258 additions & 163 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 28 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
[![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)
44
[![Latest Stable Version](http://img.shields.io/badge/Latest%20Stable-7.0.1-blue.svg)](https://packagist.org/packages/nickdnk/graph-sdk)
55
[![Downloads](https://img.shields.io/packagist/dt/nickdnk/graph-sdk?label=Downloads)](https://packagist.org/packages/nickdnk/graph-sdk)
6-
### 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.
6+
### 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.
77

8-
## PHP 7.3 is required.
8+
### PHP 8.1 is required.
99

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

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

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

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

3131
```php
32-
require_once __DIR__ . '/vendor/autoload.php'; // change path as needed
32+
require_once __DIR__ . '/vendor/autoload.php';
3333

34-
$fb = new \Facebook\Facebook([
34+
use Facebook\Facebook;
35+
use Facebook\GraphNodes\GraphUser;
36+
use Facebook\Exceptions\FacebookResponseException;
37+
use Facebook\Exceptions\FacebookSDKException;
38+
39+
$fb = new Facebook([
3540
'app_id' => '{app-id}',
3641
'app_secret' => '{app-secret}',
37-
'default_graph_version' => 'v2.10',
42+
'default_graph_version' => 'v20.0',
3843
//'default_access_token' => '{access-token}', // optional
3944
]);
4045

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

4752
try {
48-
// Get the \Facebook\GraphNodes\GraphUser object for the current user.
53+
4954
// If you provided a 'default_access_token', the '{access-token}' is optional.
5055
$response = $fb->get('/me', '{access-token}');
51-
} catch(\Facebook\Exceptions\FacebookResponseException $e) {
56+
57+
// To decode the response to a PHP class, provide the class of the root node in the response. You will have to match
58+
// this manually based on the endpoint you requested. Please do open a pull request if you want to add more types.
59+
60+
/** @var GraphUser $me */
61+
$me = $response->getGraphNode(GraphUser::class);
62+
echo 'Logged in as ' . $me->getName() . PHP_EOL;
63+
echo 'User email is ' . $me->getEmail() . PHP_EOL;
64+
65+
} catch (FacebookResponseException $e) {
66+
5267
// When Graph returns an error
5368
echo 'Graph returned an error: ' . $e->getMessage();
54-
exit;
55-
} catch(\Facebook\Exceptions\FacebookSDKException $e) {
69+
70+
} catch (FacebookSDKException $e) {
71+
5672
// When validation fails or other local issues
5773
echo 'Facebook SDK returned an error: ' . $e->getMessage();
58-
exit;
74+
5975
}
60-
61-
$me = $response->getGraphUser();
62-
echo 'Logged in as ' . $me->getName();
6376
```
6477

65-
Complete documentation, installation instructions, and examples are available [here](docs/).
66-
6778
## Tests
6879

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

7684
```bash
7785
$ ./vendor/bin/phpunit
7886
```
7987

80-
By default, the tests will send live HTTP requests to the Graph API. If you are without an internet connection you can
81-
skip these tests by excluding the `integration` group.
82-
83-
```bash
84-
$ ./vendor/bin/phpunit --exclude-group integration
85-
```
86-
8788
## License
8889

8990
Please see the [license file](https://github.com/facebook/php-graph-sdk/blob/master/LICENSE) for more information.

composer.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "nickdnk/graph-sdk",
3-
"description": "Facebook SDK for PHP compatible with PHP8",
3+
"description": "Facebook SDK for PHP 8+",
44
"keywords": ["facebook", "sdk"],
55
"type": "library",
66
"homepage": "https://github.com/nickdnk/php-graph-sdk",
@@ -12,12 +12,12 @@
1212
}
1313
],
1414
"require": {
15-
"php": "^7.3 || ^8.0"
15+
"php": "^8.1"
1616
},
1717
"require-dev": {
18-
"phpunit/phpunit": "~9.5",
19-
"mockery/mockery": "~1.5.1",
20-
"guzzlehttp/guzzle": "^6.5.0 | ^7.5.0"
18+
"phpunit/phpunit": "^9.5",
19+
"mockery/mockery": "^1.6.12",
20+
"guzzlehttp/guzzle": "^7.9.2"
2121
},
2222
"conflict": {
2323
"guzzlehttp/guzzle": "<6.0"

docs/README.md

Lines changed: 0 additions & 34 deletions
This file was deleted.

docs/examples/access_token_from_canvas.md

Lines changed: 0 additions & 41 deletions
This file was deleted.

docs/examples/access_token_from_javascript.md

Lines changed: 0 additions & 86 deletions
This file was deleted.

docs/examples/access_token_from_page_tab.md

Lines changed: 0 additions & 47 deletions
This file was deleted.

0 commit comments

Comments
 (0)