Skip to content
This repository was archived by the owner on Jan 13, 2022. It is now read-only.

Commit 2ff8ef8

Browse files
committed
Remove helpers
1 parent 010bfd9 commit 2ff8ef8

Some content is hidden

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

45 files changed

+47
-3196
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Starting with version 5, the Facebook PHP SDK follows [SemVer](http://semver.org
1111
- Replace custom CSPRNG implementation with `paragonie/random_compat` (#644)
1212
- Removed the built-in autoloader in favor of composer's autoloader (#646)
1313
- Big integers in signed requests get decoded as `string` instead of `float` (#699)
14+
- Remove helpers
1415

1516
## 5.x
1617

README.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,6 @@ $fb = new \Facebook\Facebook([
3333
//'default_access_token' => '{access-token}', // optional
3434
]);
3535

36-
// Use one of the helper classes to get a Facebook\Authentication\AccessToken entity.
37-
// $helper = $fb->getRedirectLoginHelper();
38-
// $helper = $fb->getJavaScriptHelper();
39-
// $helper = $fb->getCanvasHelper();
40-
// $helper = $fb->getPageTabHelper();
41-
4236
try {
4337
// Get the \Facebook\GraphNodes\GraphUser object for the current user.
4438
// If you provided a 'default_access_token', the '{access-token}' is optional.

docs/README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ For installation & implementation instructions, look through the [Getting Starte
1313
The following examples demonstrate how you would accomplish common tasks with the Facebook SDK for PHP.
1414

1515
- **Authentication & Signed Requests**
16-
- [Facebook Login (OAuth 2.0)](./examples/facebook_login.md)
1716
- [Obtaining an access token from the SDK for JavaScript](./examples/access_token_from_javascript.md)
1817
- [Obtaining an access token within a Facebook Canvas context](./examples/access_token_from_canvas.md)
1918
- [Obtaining an access token within a Facebook Page tab context](./examples/access_token_from_page_tab.md)

docs/examples/access_token_from_canvas.md

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,37 +4,32 @@ This example covers obtaining an access token and signed request from within the
44

55
## Example
66

7-
A signed request will be sent to your app via the HTTP POST method within the context of app canvas. The PHP SDK provides a helper to easily obtain, validate & decode the signed request. If the proper OAuth data exists in the signed request payload data, an attempt can be made to obtain an access token from the Graph API.
7+
A signed request will be sent to your app via the HTTP POST method within the context of app canvas. The PHP SDK provides a helper to validate & decode the signed request.
88

99
```php
1010
$fb = new Facebook\Facebook([
11-
'app_id' => '{app-id}',
12-
'app_secret' => '{app-secret}',
13-
'default_graph_version' => 'v2.9',
14-
]);
15-
16-
$helper = $fb->getCanvasHelper();
11+
'app_id' => '{app-id}',
12+
'app_secret' => '{app-secret}',
13+
'default_graph_version' => 'v2.9',
14+
]);
1715

1816
try {
19-
$accessToken = $helper->getAccessToken();
20-
} catch(Facebook\Exceptions\FacebookResponseException $e) {
21-
// When Graph returns an error
22-
echo 'Graph returned an error: ' . $e->getMessage();
23-
exit;
17+
$signedRequest = new SignedRequest($fb->getApp(), $_POST['signed_request'])
18+
$accessToken = $signedRequest->getAccessToken();
2419
} catch(Facebook\Exceptions\FacebookSDKException $e) {
25-
// When validation fails or other local issues
26-
echo 'Facebook SDK returned an error: ' . $e->getMessage();
27-
exit;
20+
// When validation fails or other local issues
21+
echo 'Facebook SDK returned an error: ' . $e->getMessage();
22+
exit;
2823
}
2924

30-
if (! isset($accessToken)) {
31-
echo 'No OAuth data could be obtained from the signed request. User has not authorized your app yet.';
32-
exit;
25+
if (!isset($accessToken)) {
26+
echo 'No OAuth data could be obtained from the signed request. User has not authorized your app yet.';
27+
exit;
3328
}
3429

3530
// Logged in
3631
echo '<h3>Signed Request</h3>';
37-
var_dump($helper->getSignedRequest());
32+
var_dump($signedRequest->getPayload());
3833

3934
echo '<h3>Access Token</h3>';
4035
var_dump($accessToken->getValue());

docs/examples/access_token_from_javascript.md

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -50,28 +50,24 @@ After the user successfully logs in, redirect the user (or make an AJAX request)
5050
```php
5151
# /js-login.php
5252
$fb = new Facebook\Facebook([
53-
'app_id' => '{app-id}',
54-
'app_secret' => '{app-secret}',
55-
'default_graph_version' => 'v2.9',
56-
]);
57-
58-
$helper = $fb->getJavaScriptHelper();
53+
'app_id' => '{app-id}',
54+
'app_secret' => '{app-secret}',
55+
'default_graph_version' => 'v2.9',
56+
]);
5957

6058
try {
61-
$accessToken = $helper->getAccessToken();
62-
} catch(Facebook\Exceptions\FacebookResponseException $e) {
63-
// When Graph returns an error
64-
echo 'Graph returned an error: ' . $e->getMessage();
65-
exit;
59+
$fbApp = $fb->getApp();
60+
$signedRequest = new SignedRequest($fbApp, $_COOKIE['fbsr_' . $fbApp->getId()]))
61+
$accessToken = $signedRequest->getAccessToken();
6662
} catch(Facebook\Exceptions\FacebookSDKException $e) {
67-
// When validation fails or other local issues
68-
echo 'Facebook SDK returned an error: ' . $e->getMessage();
69-
exit;
63+
// When validation fails or other local issues
64+
echo 'Facebook SDK returned an error: ' . $e->getMessage();
65+
exit;
7066
}
7167

72-
if (! isset($accessToken)) {
73-
echo 'No cookie set or no OAuth data could be obtained from cookie.';
74-
exit;
68+
if (!isset($accessToken)) {
69+
echo 'No cookie set or no OAuth data could be obtained from cookie.';
70+
exit;
7571
}
7672

7773
// Logged in

docs/examples/access_token_from_page_tab.md

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
<!-- @TODO: Rewrite doc -->
12
# Get Access Token From Page Tab Example
23

34
This example covers obtaining an access token and signed request from within the context of a page tab with the Facebook SDK for PHP.
@@ -8,39 +9,34 @@ Page tabs behave much like the app canvas. The PHP SDK provides a helper for pag
89

910
```php
1011
$fb = new Facebook\Facebook([
11-
'app_id' => '{app-id}',
12-
'app_secret' => '{app-secret}',
13-
'default_graph_version' => 'v2.9',
14-
]);
15-
16-
$helper = $fb->getPageTabHelper();
12+
'app_id' => '{app-id}',
13+
'app_secret' => '{app-secret}',
14+
'default_graph_version' => 'v2.9',
15+
]);
1716

1817
try {
19-
$accessToken = $helper->getAccessToken();
20-
} catch(Facebook\Exceptions\FacebookResponseException $e) {
21-
// When Graph returns an error
22-
echo 'Graph returned an error: ' . $e->getMessage();
23-
exit;
18+
$signedRequest = new SignedRequest($fb->getApp(), $_POST['signed_request'])
19+
$accessToken = $signedRequest->getAccessToken();
2420
} catch(Facebook\Exceptions\FacebookSDKException $e) {
25-
// When validation fails or other local issues
26-
echo 'Facebook SDK returned an error: ' . $e->getMessage();
27-
exit;
21+
// When validation fails or other local issues
22+
echo 'Facebook SDK returned an error: ' . $e->getMessage();
23+
exit;
2824
}
2925

30-
if (! isset($accessToken)) {
31-
echo 'No OAuth data could be obtained from the signed request. User has not authorized your app yet.';
32-
exit;
26+
if (!isset($accessToken)) {
27+
echo 'No OAuth data could be obtained from the signed request. User has not authorized your app yet.';
28+
exit;
3329
}
3430

3531
// Logged in
3632
echo '<h3>Page ID</h3>';
37-
var_dump($helper->getPageId());
33+
var_dump($signedRequest->get('page')['id']);
3834

3935
echo '<h3>User is admin of page</h3>';
40-
var_dump($helper->isAdmin());
36+
var_dump($signedRequest->get('page')['admin'] === true);
4137

4238
echo '<h3>Signed Request</h3>';
43-
var_dump($helper->getSignedRequest());
39+
var_dump($signedRequest->getPayload());
4440

4541
echo '<h3>Access Token</h3>';
4642
var_dump($accessToken->getValue());

docs/examples/facebook_login.md

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

0 commit comments

Comments
 (0)