Skip to content

Commit a450e54

Browse files
committed
updated source code to version 6.0. Source code is taken from nickdnk/graph-sdk:6.0
1 parent 2d82506 commit a450e54

File tree

10 files changed

+22
-136
lines changed

10 files changed

+22
-136
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
vendor/
22
composer.lock
33
tests/FacebookTestCredentials.php
4+
.idea

README.md

Lines changed: 1 addition & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Facebook SDK for PHP (v5)
1+
# Facebook SDK for PHP (v6)
22

33
[![Build Status](https://img.shields.io/travis/facebook/php-graph-sdk/5.x.svg)](https://travis-ci.org/facebook/php-graph-sdk)
44
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/facebook/php-graph-sdk/badges/quality-score.png?b=5.x)](https://scrutinizer-ci.com/g/facebook/php-graph-sdk/?branch=5.x)
@@ -14,78 +14,3 @@ The Facebook PHP SDK can be installed with [Composer](https://getcomposer.org/).
1414
composer require facebook/graph-sdk
1515
```
1616

17-
Please be aware, that there are issues when using the Facebook SDK together with [Guzzle](https://github.com/guzzle/guzzle) 6.x. php-graph-sdk v5.x only works with Guzzle 5.x out of the box. However, [there is a workaround to make it work with Guzzle 6.x](https://www.sammyk.me/how-to-inject-your-own-http-client-in-the-facebook-php-sdk-v5#writing-a-guzzle-6-http-client-implementation-from-scratch).
18-
19-
## Upgrading to v5.x
20-
21-
Upgrading from v4.x? Facebook PHP SDK v5.x introduced breaking changes. Please [read the upgrade guide](https://www.sammyk.me/upgrading-the-facebook-php-sdk-from-v4-to-v5) before upgrading.
22-
23-
## Usage
24-
25-
> **Note:** This version of the Facebook SDK for PHP requires PHP 5.4 or greater.
26-
27-
Simple GET example of a user's profile.
28-
29-
```php
30-
require_once __DIR__ . '/vendor/autoload.php'; // change path as needed
31-
32-
$fb = new \Facebook\Facebook([
33-
'app_id' => '{app-id}',
34-
'app_secret' => '{app-secret}',
35-
'default_graph_version' => 'v2.10',
36-
//'default_access_token' => '{access-token}', // optional
37-
]);
38-
39-
// Use one of the helper classes to get a Facebook\Authentication\AccessToken entity.
40-
// $helper = $fb->getRedirectLoginHelper();
41-
// $helper = $fb->getJavaScriptHelper();
42-
// $helper = $fb->getCanvasHelper();
43-
// $helper = $fb->getPageTabHelper();
44-
45-
try {
46-
// Get the \Facebook\GraphNodes\GraphUser object for the current user.
47-
// If you provided a 'default_access_token', the '{access-token}' is optional.
48-
$response = $fb->get('/me', '{access-token}');
49-
} catch(\Facebook\Exceptions\FacebookResponseException $e) {
50-
// When Graph returns an error
51-
echo 'Graph returned an error: ' . $e->getMessage();
52-
exit;
53-
} catch(\Facebook\Exceptions\FacebookSDKException $e) {
54-
// When validation fails or other local issues
55-
echo 'Facebook SDK returned an error: ' . $e->getMessage();
56-
exit;
57-
}
58-
59-
$me = $response->getGraphUser();
60-
echo 'Logged in as ' . $me->getName();
61-
```
62-
63-
Complete documentation, installation instructions, and examples are available [here](docs/).
64-
65-
## Tests
66-
67-
1. [Composer](https://getcomposer.org/) is a prerequisite for running the tests. Install composer globally, then run `composer install` to install required files.
68-
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.
69-
3. The tests can be executed by running this command from the root directory:
70-
71-
```bash
72-
$ ./vendor/bin/phpunit
73-
```
74-
75-
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.
76-
77-
```bash
78-
$ ./vendor/bin/phpunit --exclude-group integration
79-
```
80-
81-
## Contributing
82-
83-
For us to accept contributions you will have to first have signed the [Contributor License Agreement](https://developers.facebook.com/opensource/cla). Please see [CONTRIBUTING](https://github.com/facebook/php-graph-sdk/blob/master/CONTRIBUTING.md) for details.
84-
85-
## License
86-
87-
Please see the [license file](https://github.com/facebook/php-graph-sdk/blob/master/LICENSE) for more information.
88-
89-
## Security Vulnerabilities
90-
91-
If you have found a security issue, please contact the maintainers directly at [[email protected]](mailto:[email protected]).

composer.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
}
1313
],
1414
"require": {
15-
"php": "^5.4|^7.0"
15+
"php": "^7.3 || ^8.0"
1616
},
1717
"require-dev": {
1818
"phpunit/phpunit": "~4.0",
@@ -26,8 +26,7 @@
2626
"autoload": {
2727
"psr-4": {
2828
"Facebook\\": "src/Facebook/"
29-
},
30-
"files": ["src/Facebook/polyfills.php"]
29+
}
3130
},
3231
"autoload-dev": {
3332
"psr-4": {
@@ -36,7 +35,7 @@
3635
},
3736
"extra": {
3837
"branch-alias": {
39-
"dev-master": "5.x-dev"
38+
"dev-master": "6.x-dev"
4039
}
4140
}
4241
}

src/Facebook/Authentication/OAuth2Client.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ public function getAuthorizationUrl($redirectUrl, $state, array $scope = [], arr
143143
'scope' => implode(',', $scope)
144144
];
145145

146-
return static::BASE_AUTHORIZATION_URL . '/' . $this->graphVersion . '/dialog/oauth?' . http_build_query($params, null, $separator);
146+
return static::BASE_AUTHORIZATION_URL . '/' . $this->graphVersion . '/dialog/oauth?' . http_build_query($params, '', $separator);
147147
}
148148

149149
/**

src/Facebook/FacebookApp.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,11 @@ public function serialize()
9696
return implode('|', [$this->id, $this->secret]);
9797
}
9898

99+
public function __serialize()
100+
{
101+
return ['id' => $this->id, 'secret' => $this->secret];
102+
}
103+
99104
/**
100105
* Unserializes a string as a FacebookApp entity.
101106
*
@@ -107,4 +112,9 @@ public function unserialize($serialized)
107112

108113
$this->__construct($id, $secret);
109114
}
115+
116+
public function __unserialize($data)
117+
{
118+
$this->__construct($data['id'], $data['secret']);
119+
}
110120
}

src/Facebook/Helpers/FacebookRedirectLoginHelper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ public function getLogoutUrl($accessToken, $next, $separator = '&')
168168
'access_token' => $accessToken->getValue(),
169169
];
170170

171-
return 'https://www.facebook.com/logout.php?' . http_build_query($params, null, $separator);
171+
return 'https://www.facebook.com/logout.php?' . http_build_query($params, '', $separator);
172172
}
173173

174174
/**

src/Facebook/Http/RequestBodyMultipart.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ private function getParamString($name, $value)
144144
*/
145145
private function getNestedParams(array $params)
146146
{
147-
$query = http_build_query($params, null, '&');
147+
$query = http_build_query($params);
148148
$params = explode('&', $query);
149149
$result = [];
150150

src/Facebook/Http/RequestBodyUrlEncoded.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,6 @@ public function __construct(array $params)
5050
*/
5151
public function getBody()
5252
{
53-
return http_build_query($this->params, null, '&');
53+
return http_build_query($this->params);
5454
}
5555
}

src/Facebook/Url/FacebookUrlManipulator.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public static function removeParamsFromUrl($url, array $paramsToFilter)
5353
}
5454

5555
if (count($params) > 0) {
56-
$query = '?' . http_build_query($params, null, '&');
56+
$query = '?' . http_build_query($params);
5757
}
5858
}
5959

@@ -81,7 +81,7 @@ public static function appendParamsToUrl($url, array $newParams = [])
8181
}
8282

8383
if (strpos($url, '?') === false) {
84-
return $url . '?' . http_build_query($newParams, null, '&');
84+
return $url . '?' . http_build_query($newParams);
8585
}
8686

8787
list($path, $query) = explode('?', $url, 2);
@@ -94,7 +94,7 @@ public static function appendParamsToUrl($url, array $newParams = [])
9494
// Sort for a predicable order
9595
ksort($newParams);
9696

97-
return $path . '?' . http_build_query($newParams, null, '&');
97+
return $path . '?' . http_build_query($newParams);
9898
}
9999

100100
/**

src/Facebook/polyfills.php

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

0 commit comments

Comments
 (0)