You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jan 13, 2022. It is now read-only.
Copy file name to clipboardExpand all lines: docs/examples/access_token_from_canvas.md
+4-8Lines changed: 4 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,19 +1,16 @@
1
-
<card>
2
1
# Get Access Token From App Canvas Example
3
2
4
3
This example covers obtaining an access token and signed request from within the context of an app canvas with the Facebook SDK for PHP.
5
-
</card>
6
4
7
-
<card>
8
-
## Example {#example}
5
+
## Example
9
6
10
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.
Copy file name to clipboardExpand all lines: docs/examples/access_token_from_javascript.md
+7-11Lines changed: 7 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,15 +1,12 @@
1
-
<card>
2
1
# Getting Access Token From The JavaScript SDK Example
3
2
4
3
This example covers obtaining an access token and signed request from the Facebook JavaScript SDK with the Facebook SDK for PHP.
5
-
</card>
6
4
7
-
<card>
8
-
## Example {#example}
5
+
## Example
9
6
10
7
In order to have the JavaScript SDK set a cookie containing a signed request (which contains information about the logged in user), you must first initialize the JavaScript SDK with the `{cookie: true}` option.
11
8
12
-
~~~~
9
+
```html
13
10
<html>
14
11
<body>
15
12
@@ -32,7 +29,7 @@ In order to have the JavaScript SDK set a cookie containing a signed request (wh
32
29
FB.init({
33
30
appId:'your-app-id',
34
31
cookie:true, // This is important, it's not enabled by default
35
-
version: 'v2.6'
32
+
version:'v2.8'
36
33
});
37
34
};
38
35
@@ -46,16 +43,16 @@ In order to have the JavaScript SDK set a cookie containing a signed request (wh
46
43
</script>
47
44
</body>
48
45
</html>
49
-
~~~~
46
+
```
50
47
51
48
After the user successfully logs in, redirect the user (or make an AJAX request) to a PHP script that obtains an access token from the signed request that exists in the cookie.
Copy file name to clipboardExpand all lines: docs/examples/batch_request.md
+11-20Lines changed: 11 additions & 20 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,19 +1,16 @@
1
-
<card>
2
1
# Batch Request Example
3
2
4
3
This example covers sending a batch request with the Facebook SDK for PHP.
5
-
</card>
6
4
7
-
<card>
8
-
## Example {#example}
5
+
## Example
9
6
10
7
The following example assumes we have the following permissions granted from the user: `user_likes`, `user_events`, `user_photos`, `publish_actions`. The example makes use of [JSONPath to reference specific batch operations](https://developers.facebook.com/docs/graph-api/making-multiple-requests/#operations).
11
8
12
-
~~~~
9
+
```php
13
10
$fb = new Facebook\Facebook([
14
11
'app_id' => '{app-id}',
15
12
'app_secret' => '{app-secret}',
16
-
'default_graph_version' => 'v2.6',
13
+
'default_graph_version' => 'v2.8',
17
14
]);
18
15
19
16
// Since all the requests will be sent on behalf of the same user,
There five requests being made in this batch requests.
83
80
@@ -89,32 +86,27 @@ There five requests being made in this batch requests.
89
86
90
87
If the request was successful, the user should have a new status update similar to this:
91
88
92
-
~~~~
89
+
```
93
90
My name is Foo User.
94
91
95
92
I like this page: Facebook Developers.
96
93
97
94
My next 2 events are House Warming Party,Some Foo Event.
98
-
~~~~
95
+
```
99
96
100
97
It should also contain a response containing two photos from the user.
101
98
102
-
%FB(devsite:markdown-wiki:info-card {
103
-
content: "The response object should return a `null` response for any request that was pointed to with JSONPath as is [the behaviour of the batch functionality of the Graph API](https://developers.facebook.com/docs/graph-api/making-multiple-requests/#operations).",
104
-
type: 'warning',
105
-
})
106
-
</card>
99
+
> **Warning:** The response object should return a `null` response for any request that was pointed to with JSONPath as is [the behaviour of the batch functionality of the Graph API](https://developers.facebook.com/docs/graph-api/making-multiple-requests/#operations).
107
100
108
-
<card>
109
-
## Multiple User Example {#multiple-user-example}
101
+
## Multiple User Example
110
102
111
103
Since the requests sent in a batch are unrelated by default, we can make requests on behalf of multiple users and pages in the same batch request.
Copy file name to clipboardExpand all lines: docs/examples/batch_upload.md
+4-8Lines changed: 4 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,21 +1,18 @@
1
-
<card>
2
1
# Batch File Upload Example
3
2
4
3
This example covers uploading files in a batch request with the Facebook SDK for PHP.
5
-
</card>
6
4
7
-
<card>
8
-
## Example {#example}
5
+
## Example
9
6
10
7
The Graph API supports [file uploads in batch requests](https://developers.facebook.com/docs/graph-api/making-multiple-requests#binary) and the Facebook PHP SDK does all the heavy lifting to make it super easy to upload photos and videos in a batch request.
11
8
12
9
The following example will upload two photos and one video.
13
10
14
-
~~~~
11
+
```php
15
12
$fb = new Facebook\Facebook([
16
13
'app_id' => '{app-id}',
17
14
'app_secret' => '{app-secret}',
18
-
'default_graph_version' => 'v2.6',
15
+
'default_graph_version' => 'v2.8',
19
16
]);
20
17
21
18
// Since all the requests will be sent on behalf of the same user,
Copy file name to clipboardExpand all lines: docs/examples/facebook_login.md
+9-17Lines changed: 9 additions & 17 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,25 +1,20 @@
1
-
<card>
2
1
# Facebook Login Example
3
2
4
3
This example covers Facebook Login with the Facebook SDK for PHP.
5
-
</card>
6
4
7
-
<card>
8
-
## Example {#example}
5
+
## Example
9
6
10
7
Although it's common to see examples of Facebook Login being implemented in one PHP script, is best to use two separate PHP scripts for more separation and more control over the responses.
11
8
12
9
In this example, the PHP script that generates the login link is called `/login.php`. The callback URL that Facebook redirects the user to after login dialog is called `/fb-callback.php`.
Copy file name to clipboardExpand all lines: docs/examples/pagination_basic.md
+4-8Lines changed: 4 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,21 +1,18 @@
1
-
<card>
2
1
# Pagination Example
3
2
4
3
This example covers basic cursor pagination with the Facebook SDK for PHP.
5
-
</card>
6
4
7
-
<card>
8
-
## Example {#example}
5
+
## Example
9
6
10
7
The Graph API supports [several methods to paginate over response data](https://developers.facebook.com/docs/graph-api/using-graph-api/#paging). The PHP SDK supports cursor-based pagination out of the box. It does all the heavy lifting of managing page cursors for you.
11
8
12
9
In this example we'll pull five entries from a user's feed (assuming the user approved the `read_stream` permission for your app). Then we'll use the `next()` method to grab the next page of results. Naturally you'd provide some sort of pagination navigation in your app, but this is just an example to get you started.
Copy file name to clipboardExpand all lines: docs/examples/post_links.md
+6-10Lines changed: 6 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,21 +1,18 @@
1
-
<card>
2
1
# Post Links Using the Graph API
3
2
4
3
This example covers posting a link to the current user's timeline using the Graph API and Facebook SDK for PHP.
5
4
6
-
It assumes that you've already obtained an access token from one of the helpers found [here](/docs/php/sdk_reference#helpers). The access token must have the `publish_actions` permission for this to work.
5
+
It assumes that you've already obtained an access token from one of the helpers found [here](../reference.md). The access token must have the `publish_actions` permission for this to work.
7
6
8
-
For more information, see the documentation for [`Facebook\Facebook`](/docs/php/Facebook), [`Facebook\FacebookResponse`](/docs/php/FacebookResponse), [`Facebook\GraphNodes\GraphNode`](/docs/php/GraphNode), [`Facebook\Exceptions\FacebookSDKException`](/docs/php/FacebookSDKException) and [`Facebook\Exceptions\FacebookResponseException`](/docs/php/FacebookResponseException).
9
-
</card>
7
+
For more information, see the documentation for [`Facebook\Facebook`](../reference/Facebook.md), [`Facebook\FacebookResponse`](../reference/FacebookResponse.md), [`Facebook\GraphNodes\GraphNode`](../reference/GraphNode.md), [`Facebook\Exceptions\FacebookSDKException`](../reference/FacebookSDKException.md) and [`Facebook\Exceptions\FacebookResponseException`](../reference/FacebookResponseException.md).
10
8
11
-
<card>
12
-
## Example {#example}
9
+
## Example
13
10
14
-
~~~~
11
+
```php
15
12
$fb = new Facebook\Facebook([
16
13
'app_id' => '{app-id}',
17
14
'app_secret' => '{app-secret}',
18
-
'default_graph_version' => 'v2.6',
15
+
'default_graph_version' => 'v2.8',
19
16
]);
20
17
21
18
$linkData = [
@@ -37,7 +34,6 @@ try {
37
34
$graphNode = $response->getGraphNode();
38
35
39
36
echo 'Posted with id: ' . $graphNode['id'];
40
-
~~~~
37
+
```
41
38
42
39
Note that the 'message' field must come from the user, as pre-filled content is forbidden by the [Platform Policies](https://developers.intern.facebook.com/policy/#control) (2.3).
Copy file name to clipboardExpand all lines: docs/examples/retrieve_user_profile.md
+6-10Lines changed: 6 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,21 +1,18 @@
1
-
<card>
2
1
# Retrieve User Profile via the Graph API
3
2
4
3
This example covers getting profile information for the current user and printing their name, using the Graph API and the Facebook SDK for PHP.
5
4
6
-
It assumes that you've already obtained an access token from one of the helpers found [here](/docs/php/sdk_reference#helpers).
5
+
It assumes that you've already obtained an access token from one of the helpers found [here](../reference.md).
7
6
8
-
For more information, see the documentation for [`Facebook\Facebook`](/docs/php/Facebook), [`Facebook\FacebookResponse`](/docs/php/FacebookResponse), [`Facebook\GraphNodes\GraphUser`](/docs/php/GraphNode#user-instance-methods), [`Facebook\Exceptions\FacebookSDKException`](/docs/php/FacebookSDKException) and [`Facebook\Exceptions\FacebookResponseException`](/docs/php/FacebookResponseException).
9
-
</card>
7
+
For more information, see the documentation for [`Facebook\Facebook`](../reference/Facebook.md), [`Facebook\FacebookResponse`](../reference/FacebookResponse.md), [`Facebook\GraphNodes\GraphUser`](../reference/GraphNode.md#graphuser-instance-methods), [`Facebook\Exceptions\FacebookSDKException`](../reference/FacebookSDKException.md) and [`Facebook\Exceptions\FacebookResponseException`](../reference/FacebookResponseException.md).
0 commit comments