From 722a0e2f31bdcf94e6bd7e9d05ba16facf50c79d Mon Sep 17 00:00:00 2001 From: Martin de Keijzer Date: Wed, 12 Apr 2023 10:01:29 +0200 Subject: [PATCH] Bump Graph API to supported 10.x version --- CHANGELOG.md | 3 ++- README.md | 2 +- docs/examples/access_token_from_canvas.md | 2 +- docs/examples/access_token_from_javascript.md | 4 ++-- docs/examples/access_token_from_page_tab.md | 2 +- docs/examples/batch_request.md | 4 ++-- docs/examples/batch_upload.md | 2 +- docs/examples/facebook_login.md | 4 ++-- docs/examples/pagination_basic.md | 2 +- docs/examples/post_links.md | 2 +- docs/examples/retrieve_user_profile.md | 2 +- docs/examples/upload_photo.md | 2 +- docs/examples/upload_video.md | 2 +- docs/getting_started.md | 2 +- docs/reference/Facebook.md | 8 ++++---- docs/reference/Request.md | 2 +- tests/BatchResponseTest.php | 16 ++++++++-------- tests/FileUpload/ResumableUploaderTest.php | 6 +++--- tests/Url/UrlManipulatorTest.php | 2 +- 19 files changed, 35 insertions(+), 34 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3dbef04bf..36df64c7f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/README.md b/README.md index 66f89ff40..442e26c25 100644 --- a/README.md +++ b/README.md @@ -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 ]); diff --git a/docs/examples/access_token_from_canvas.md b/docs/examples/access_token_from_canvas.md index 65c4a63a6..0d6f8e266 100644 --- a/docs/examples/access_token_from_canvas.md +++ b/docs/examples/access_token_from_canvas.md @@ -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(); diff --git a/docs/examples/access_token_from_javascript.md b/docs/examples/access_token_from_javascript.md index a07199bbb..b8111b672 100644 --- a/docs/examples/access_token_from_javascript.md +++ b/docs/examples/access_token_from_javascript.md @@ -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' }); }; @@ -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(); diff --git a/docs/examples/access_token_from_page_tab.md b/docs/examples/access_token_from_page_tab.md index 3f4d95c84..72409a5d0 100644 --- a/docs/examples/access_token_from_page_tab.md +++ b/docs/examples/access_token_from_page_tab.md @@ -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(); diff --git a/docs/examples/batch_request.md b/docs/examples/batch_request.md index 97dacc9b3..c681e84eb 100644 --- a/docs/examples/batch_request.md +++ b/docs/examples/batch_request.md @@ -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, @@ -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 = [ diff --git a/docs/examples/batch_upload.md b/docs/examples/batch_upload.md index 4477a6de5..43aba7687 100644 --- a/docs/examples/batch_upload.md +++ b/docs/examples/batch_upload.md @@ -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, diff --git a/docs/examples/facebook_login.md b/docs/examples/facebook_login.md index ac894e254..57abd982c 100644 --- a/docs/examples/facebook_login.md +++ b/docs/examples/facebook_login.md @@ -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(); @@ -31,7 +31,7 @@ echo 'Log in with Facebook!'; $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(); diff --git a/docs/examples/pagination_basic.md b/docs/examples/pagination_basic.md index 32f96e0b6..a12740372 100644 --- a/docs/examples/pagination_basic.md +++ b/docs/examples/pagination_basic.md @@ -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 { diff --git a/docs/examples/post_links.md b/docs/examples/post_links.md index b92f26db3..d6182a2ee 100644 --- a/docs/examples/post_links.md +++ b/docs/examples/post_links.md @@ -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 = [ diff --git a/docs/examples/retrieve_user_profile.md b/docs/examples/retrieve_user_profile.md index 8255663de..16f5175e8 100644 --- a/docs/examples/retrieve_user_profile.md +++ b/docs/examples/retrieve_user_profile.md @@ -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 { diff --git a/docs/examples/upload_photo.md b/docs/examples/upload_photo.md index a56743ac7..a320ceff4 100644 --- a/docs/examples/upload_photo.md +++ b/docs/examples/upload_photo.md @@ -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 = [ diff --git a/docs/examples/upload_video.md b/docs/examples/upload_video.md index 95243e9d2..6a18434b3 100644 --- a/docs/examples/upload_video.md +++ b/docs/examples/upload_video.md @@ -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 = [ diff --git a/docs/getting_started.md b/docs/getting_started.md index f900462d8..5ee0b478e 100644 --- a/docs/getting_started.md +++ b/docs/getting_started.md @@ -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', ]); ``` diff --git a/docs/reference/Facebook.md b/docs/reference/Facebook.md index 4203d0fd8..10db9a055 100644 --- a/docs/reference/Facebook.md +++ b/docs/reference/Facebook.md @@ -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', // . . . ]); ``` @@ -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(), @@ -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', ]); ``` @@ -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() diff --git a/docs/reference/Request.md b/docs/reference/Request.md index cfb0f684c..13640ecfe 100644 --- a/docs/reference/Request.md +++ b/docs/reference/Request.md @@ -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 ``` diff --git a/tests/BatchResponseTest.php b/tests/BatchResponseTest.php index 397c71d05..57f83509c 100755 --- a/tests/BatchResponseTest.php +++ b/tests/BatchResponseTest.php @@ -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, [ @@ -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); @@ -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()); } diff --git a/tests/FileUpload/ResumableUploaderTest.php b/tests/FileUpload/ResumableUploaderTest.php index bbf550972..9df97d379 100644 --- a/tests/FileUpload/ResumableUploaderTest.php +++ b/tests/FileUpload/ResumableUploaderTest.php @@ -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); @@ -82,7 +82,7 @@ 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); } @@ -90,7 +90,7 @@ public function testStartWillLetErrorResponsesThrow(): void 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); diff --git a/tests/Url/UrlManipulatorTest.php b/tests/Url/UrlManipulatorTest.php index 64a41d939..6c0c127a7 100644 --- a/tests/Url/UrlManipulatorTest.php +++ b/tests/Url/UrlManipulatorTest.php @@ -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);