Skip to content

Commit

Permalink
Bump Graph API to supported 10.x version
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin de Keijzer committed Apr 12, 2023
1 parent ec00565 commit 722a0e2
Show file tree
Hide file tree
Showing 19 changed files with 35 additions and 34 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# CHANGELOG

## 7.x

- 7.0.2
- Bump default Graph API version to v10.0
- 7.0.1
- Fix a bug with required Composer packages
- 7.0.0
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ require_once __DIR__ . '/vendor/autoload.php'; // change path as needed
$fb = new \Facebook\Facebook([
'app_id' => '{app-id}',
'app_secret' => '{app-secret}',
'default_graph_version' => 'v2.10',
'default_graph_version' => 'v10.0',
//'default_access_token' => '{access-token}', // optional
]);

Expand Down
2 changes: 1 addition & 1 deletion docs/examples/access_token_from_canvas.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ A signed request will be sent to your app via the HTTP POST method within the co
$fb = new Facebook\Facebook([
'app_id' => '{app-id}',
'app_secret' => '{app-secret}',
'default_graph_version' => 'v2.10',
'default_graph_version' => 'v10.0',
]);

$helper = $fb->getCanvasHelper();
Expand Down
4 changes: 2 additions & 2 deletions docs/examples/access_token_from_javascript.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ In order to have the JavaScript SDK set a cookie containing a signed request (wh
FB.init({
appId: 'your-app-id',
cookie: true, // This is important, it's not enabled by default
version: 'v2.10'
version: 'v10.0'
});
};
Expand All @@ -52,7 +52,7 @@ After the user successfully logs in, redirect the user (or make an AJAX request)
$fb = new Facebook\Facebook([
'app_id' => '{app-id}',
'app_secret' => '{app-secret}',
'default_graph_version' => 'v2.10',
'default_graph_version' => 'v10.0',
]);

$helper = $fb->getJavaScriptHelper();
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/access_token_from_page_tab.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Page tabs behave much like the app canvas. The PHP SDK provides a helper for pag
$fb = new Facebook\Facebook([
'app_id' => '{app-id}',
'app_secret' => '{app-secret}',
'default_graph_version' => 'v2.10',
'default_graph_version' => 'v10.0',
]);

$helper = $fb->getPageTabHelper();
Expand Down
4 changes: 2 additions & 2 deletions docs/examples/batch_request.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ The following example assumes we have the following permissions granted from the
$fb = new Facebook\Facebook([
'app_id' => '{app-id}',
'app_secret' => '{app-secret}',
'default_graph_version' => 'v2.10',
'default_graph_version' => 'v10.0',
]);

// Since all the requests will be sent on behalf of the same user,
Expand Down Expand Up @@ -106,7 +106,7 @@ Since the requests sent in a batch are unrelated by default, we can make request
$fb = new Facebook\Facebook([
'app_id' => '{app-id}',
'app_secret' => '{app-secret}',
'default_graph_version' => 'v2.10',
'default_graph_version' => 'v10.0',
]);

$batch = [
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/batch_upload.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ The following example will upload two photos and one video.
$fb = new Facebook\Facebook([
'app_id' => '{app-id}',
'app_secret' => '{app-secret}',
'default_graph_version' => 'v2.10',
'default_graph_version' => 'v10.0',
]);

// Since all the requests will be sent on behalf of the same user,
Expand Down
4 changes: 2 additions & 2 deletions docs/examples/facebook_login.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ In this example, the PHP script that generates the login link is called `/login.
$fb = new Facebook\Facebook([
'app_id' => '{app-id}',
'app_secret' => '{app-secret}',
'default_graph_version' => 'v2.10',
'default_graph_version' => 'v10.0',
]);

$helper = $fb->getRedirectLoginHelper();
Expand All @@ -31,7 +31,7 @@ echo '<a href="' . $loginUrl . '">Log in with Facebook!</a>';
$fb = new Facebook\Facebook([
'app_id' => '{app-id}',
'app_secret' => '{app-secret}',
'default_graph_version' => 'v2.10',
'default_graph_version' => 'v10.0',
]);

$helper = $fb->getRedirectLoginHelper();
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/pagination_basic.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ In this example we'll pull five entries from a user's feed (assuming the user ap
$fb = new Facebook\Facebook([
'app_id' => '{app-id}',
'app_secret' => '{app-secret}',
'default_graph_version' => 'v2.10',
'default_graph_version' => 'v10.0',
]);

try {
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/post_links.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ For more information, see the documentation for [`Facebook\Facebook`](../referen
$fb = new Facebook\Facebook([
'app_id' => '{app-id}',
'app_secret' => '{app-secret}',
'default_graph_version' => 'v2.10',
'default_graph_version' => 'v10.0',
]);

$linkData = [
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/retrieve_user_profile.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ For more information, see the documentation for [`Facebook\Facebook`](../referen
$fb = new Facebook\Facebook([
'app_id' => '{app-id}',
'app_secret' => '{app-secret}',
'default_graph_version' => 'v2.10',
'default_graph_version' => 'v10.0',
]);

try {
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/upload_photo.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ For more information, see the documentation for [`Facebook\Facebook`](../referen
$fb = new Facebook\Facebook([
'app_id' => '{app-id}',
'app_secret' => '{app-secret}',
'default_graph_version' => 'v2.10',
'default_graph_version' => 'v10.0',
]);

$data = [
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/upload_video.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ The following example will upload a video in chunks using the [resumable upload]
$fb = new Facebook\Facebook([
'app_id' => '{app-id}',
'app_secret' => '{app-secret}',
'default_graph_version' => 'v2.10',
'default_graph_version' => 'v10.0',
]);

$data = [
Expand Down
2 changes: 1 addition & 1 deletion docs/getting_started.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Before we can send requests to the Graph API, we need to load our app configurat
$fb = new Facebook\Facebook([
'app_id' => '{app-id}',
'app_secret' => '{app-secret}',
'default_graph_version' => 'v2.10',
'default_graph_version' => 'v10.0',
]);
```

Expand Down
8 changes: 4 additions & 4 deletions docs/reference/Facebook.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ To instantiate a new `Facebook\Facebook` service, pass an array of configuration
$fb = new Facebook\Facebook([
'app_id' => '{app-id}',
'app_secret' => '{app-secret}',
'default_graph_version' => 'v2.10',
'default_graph_version' => 'v10.0',
// . . .
]);
```
Expand Down Expand Up @@ -48,7 +48,7 @@ $fb = new Facebook\Facebook([
'app_secret' => '{app-secret}',
'default_access_token' => '{access-token}',
'enable_beta_mode' => true,
'default_graph_version' => 'v2.10',
'default_graph_version' => 'v10.0',
'http_client_handler' => 'guzzle',
'persistent_data_handler' => 'memory',
'url_detection_handler' => new MyUrlDetectionHandler(),
Expand Down Expand Up @@ -123,7 +123,7 @@ To take advantage of this feature, simply set an environment variable named `FAC

```php
$fb = new Facebook\Facebook([
'default_graph_version' => 'v2.10',
'default_graph_version' => 'v10.0',
]);
```

Expand Down Expand Up @@ -295,7 +295,7 @@ public Facebook\Response sendRequest(
Sends a request to the Graph API.

```php
$response = $fb->sendRequest('GET', '/me', [], '{access-token}', 'eTag', 'v2.10');
$response = $fb->sendRequest('GET', '/me', [], '{access-token}', 'eTag', 'v10.0');
```

## sendBatchRequest()
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/Request.md
Original file line number Diff line number Diff line change
Expand Up @@ -176,5 +176,5 @@ $fb = new Facebook\Facebook(/* . . . */);
$request = $fb->request('GET', '/me', ['fields' => 'id,name']);

$url = $request->getUrl();
// /v2.10/me?fields=id,name&access_token=token&appsecret_proof=proof
// /v10.0/me?fields=id,name&access_token=token&appsecret_proof=proof
```
16 changes: 8 additions & 8 deletions tests/BatchResponseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,13 @@ public function testASuccessfulJsonBatchResponseWillBeDecoded(): void
{
$graphResponseJson = '[';
// Single Graph object.
$graphResponseJson .= '{"code":200,"headers":[{"name":"Connection","value":"close"},{"name":"Last-Modified","value":"2013-12-24T00:34:20+0000"},{"name":"Facebook-API-Version","value":"v2.0"},{"name":"ETag","value":"\"fooTag\""},{"name":"Content-Type","value":"text\/javascript; charset=UTF-8"},{"name":"Pragma","value":"no-cache"},{"name":"Access-Control-Allow-Origin","value":"*"},{"name":"Cache-Control","value":"private, no-cache, no-store, must-revalidate"},{"name":"Expires","value":"Sat, 01 Jan 2000 00:00:00 GMT"}],"body":"{\"id\":\"123\",\"name\":\"Foo McBar\",\"updated_time\":\"2013-12-24T00:34:20+0000\",\"verified\":true}"}';
$graphResponseJson .= '{"code":200,"headers":[{"name":"Connection","value":"close"},{"name":"Last-Modified","value":"2013-12-24T00:34:20+0000"},{"name":"Facebook-API-Version","value":"v10.0"},{"name":"ETag","value":"\"fooTag\""},{"name":"Content-Type","value":"text\/javascript; charset=UTF-8"},{"name":"Pragma","value":"no-cache"},{"name":"Access-Control-Allow-Origin","value":"*"},{"name":"Cache-Control","value":"private, no-cache, no-store, must-revalidate"},{"name":"Expires","value":"Sat, 01 Jan 2000 00:00:00 GMT"}],"body":"{\"id\":\"123\",\"name\":\"Foo McBar\",\"updated_time\":\"2013-12-24T00:34:20+0000\",\"verified\":true}"}';
// Paginated list of Graph objects.
$graphResponseJson .= ',{"code":200,"headers":[{"name":"Connection","value":"close"},{"name":"Facebook-API-Version","value":"v1.0"},{"name":"ETag","value":"\"barTag\""},{"name":"Content-Type","value":"text\/javascript; charset=UTF-8"},{"name":"Pragma","value":"no-cache"},{"name":"Access-Control-Allow-Origin","value":"*"},{"name":"Cache-Control","value":"private, no-cache, no-store, must-revalidate"},{"name":"Expires","value":"Sat, 01 Jan 2000 00:00:00 GMT"}],"body":"{\"data\":[{\"id\":\"1337\",\"story\":\"Foo story.\"},{\"id\":\"1338\",\"story\":\"Bar story.\"}],\"paging\":{\"previous\":\"previous_url\",\"next\":\"next_url\"}}"}';
// After POST operation.
$graphResponseJson .= ',{"code":200,"headers":[{"name":"Connection","value":"close"},{"name":"Expires","value":"Sat, 01 Jan 2000 00:00:00 GMT"},{"name":"Cache-Control","value":"private, no-cache, no-store, must-revalidate"},{"name":"Access-Control-Allow-Origin","value":"*"},{"name":"Pragma","value":"no-cache"},{"name":"Content-Type","value":"text\/javascript; charset=UTF-8"},{"name":"Facebook-API-Version","value":"v2.0"}],"body":"{\"id\":\"123_1337\"}"}';
$graphResponseJson .= ',{"code":200,"headers":[{"name":"Connection","value":"close"},{"name":"Expires","value":"Sat, 01 Jan 2000 00:00:00 GMT"},{"name":"Cache-Control","value":"private, no-cache, no-store, must-revalidate"},{"name":"Access-Control-Allow-Origin","value":"*"},{"name":"Pragma","value":"no-cache"},{"name":"Content-Type","value":"text\/javascript; charset=UTF-8"},{"name":"Facebook-API-Version","value":"v10.0"}],"body":"{\"id\":\"123_1337\"}"}';
// After DELETE operation.
$graphResponseJson .= ',{"code":200,"headers":[{"name":"Connection","value":"close"},{"name":"Expires","value":"Sat, 01 Jan 2000 00:00:00 GMT"},{"name":"Cache-Control","value":"private, no-cache, no-store, must-revalidate"},{"name":"Access-Control-Allow-Origin","value":"*"},{"name":"Pragma","value":"no-cache"},{"name":"Content-Type","value":"text\/javascript; charset=UTF-8"},{"name":"Facebook-API-Version","value":"v2.0"}],"body":"true"}';
$graphResponseJson .= ',{"code":200,"headers":[{"name":"Connection","value":"close"},{"name":"Expires","value":"Sat, 01 Jan 2000 00:00:00 GMT"},{"name":"Cache-Control","value":"private, no-cache, no-store, must-revalidate"},{"name":"Access-Control-Allow-Origin","value":"*"},{"name":"Pragma","value":"no-cache"},{"name":"Content-Type","value":"text\/javascript; charset=UTF-8"},{"name":"Facebook-API-Version","value":"v10.0"}],"body":"true"}';
$graphResponseJson .= ']';
$response = new Response($this->request, $graphResponseJson, 200);
$batchRequest = new BatchRequest($this->app, [
Expand Down Expand Up @@ -140,8 +140,8 @@ public function testTheOriginalRequestCanBeObtainedForEachRequest(): void
public function testHeadersFromBatchRequestCanBeAccessed(): void
{
$graphResponseJson = '[';
$graphResponseJson .= '{"code":200,"headers":[{"name":"Facebook-API-Version","value":"v2.0"},{"name":"ETag","value":"\"fooTag\""}],"body":"{\"foo\":\"bar\"}"}';
$graphResponseJson .= ',{"code":200,"headers":[{"name":"Facebook-API-Version","value":"v2.5"},{"name":"ETag","value":"\"barTag\""}],"body":"{\"foo\":\"bar\"}"}';
$graphResponseJson .= '{"code":200,"headers":[{"name":"Facebook-API-Version","value":"v10.0"},{"name":"ETag","value":"\"fooTag\""}],"body":"{\"foo\":\"bar\"}"}';
$graphResponseJson .= ',{"code":200,"headers":[{"name":"Facebook-API-Version","value":"v10.4"},{"name":"ETag","value":"\"barTag\""}],"body":"{\"foo\":\"bar\"}"}';
$graphResponseJson .= ']';
$response = new Response($this->request, $graphResponseJson, 200);

Expand All @@ -153,12 +153,12 @@ public function testHeadersFromBatchRequestCanBeAccessed(): void
$batchRequest = new BatchRequest($this->app, $requests);
$batchResponse = new BatchResponse($batchRequest, $response);

$this->assertEquals('v2.0', $batchResponse[0]->getGraphVersion());
$this->assertEquals('v10.0', $batchResponse[0]->getGraphVersion());
$this->assertEquals('"fooTag"', $batchResponse[0]->getETag());
$this->assertEquals('v2.5', $batchResponse[1]->getGraphVersion());
$this->assertEquals('v10.4', $batchResponse[1]->getGraphVersion());
$this->assertEquals('"barTag"', $batchResponse[1]->getETag());
$this->assertEquals([
'Facebook-API-Version' => 'v2.5',
'Facebook-API-Version' => 'v10.4',
'ETag' => '"barTag"',
], $batchResponse[1]->getHeaders());
}
Expand Down
6 changes: 3 additions & 3 deletions tests/FileUpload/ResumableUploaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ protected function setUp(): void

public function testResumableUploadCanStartTransferAndFinish(): void
{
$uploader = new ResumableUploader($this->fbApp, $this->client, 'access_token', 'v2.4');
$uploader = new ResumableUploader($this->fbApp, $this->client, 'access_token', 'v10.0');
$endpoint = '/me/videos';
$chunk = $uploader->start($endpoint, $this->file);
$this->assertInstanceOf(TransferChunk::class, $chunk);
Expand All @@ -82,15 +82,15 @@ public function testStartWillLetErrorResponsesThrow(): void
{
$this->expectException(\Facebook\Exception\ResponseException::class);
$this->graphApi->failOnStart();
$uploader = new ResumableUploader($this->fbApp, $this->client, 'access_token', 'v2.4');
$uploader = new ResumableUploader($this->fbApp, $this->client, 'access_token', 'v10.0');

$uploader->start('/me/videos', $this->file);
}

public function testFailedResumableTransferWillNotThrowAndReturnSameChunk(): void
{
$this->graphApi->failOnTransfer();
$uploader = new ResumableUploader($this->fbApp, $this->client, 'access_token', 'v2.4');
$uploader = new ResumableUploader($this->fbApp, $this->client, 'access_token', 'v10.0');

$chunk = new TransferChunk($this->file, '1', '2', '3', '4');
$newChunk = $uploader->transfer('/me/videos', $chunk);
Expand Down
2 changes: 1 addition & 1 deletion tests/Url/UrlManipulatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ public function testGraphUrlsCanBeTrimmed(): void
$baseGraphUrl = UrlManipulator::baseGraphUrlEndpoint($fullGraphUrl);
$this->assertEquals('/me', $baseGraphUrl);

$fullGraphUrl = 'https://whatever-they-want.facebook.com/v2.1/me';
$fullGraphUrl = 'https://whatever-they-want.facebook.com/v10.0/me';
$baseGraphUrl = UrlManipulator::baseGraphUrlEndpoint($fullGraphUrl);
$this->assertEquals('/me', $baseGraphUrl);

Expand Down

0 comments on commit 722a0e2

Please sign in to comment.