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

Commit 2465b15

Browse files
authored
Merge pull request #681 from nayafia/md-convert
Convert docs to Markdown
2 parents 08a2c49 + c66d010 commit 2465b15

36 files changed

+1133
-1712
lines changed

docs/examples/access_token_from_canvas.md

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,16 @@
1-
<card>
21
# Get Access Token From App Canvas Example
32

43
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>
64

7-
<card>
8-
## Example {#example}
5+
## Example
96

107
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.
118

12-
~~~~
9+
```php
1310
$fb = new Facebook\Facebook([
1411
'app_id' => '{app-id}',
1512
'app_secret' => '{app-secret}',
16-
'default_graph_version' => 'v2.6',
13+
'default_graph_version' => 'v2.8',
1714
]);
1815

1916
$helper = $fb->getCanvasHelper();
@@ -41,5 +38,4 @@ var_dump($helper->getSignedRequest());
4138

4239
echo '<h3>Access Token</h3>';
4340
var_dump($accessToken->getValue());
44-
~~~~
45-
</card>
41+
```

docs/examples/access_token_from_javascript.md

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
1-
<card>
21
# Getting Access Token From The JavaScript SDK Example
32

43
This example covers obtaining an access token and signed request from the Facebook JavaScript SDK with the Facebook SDK for PHP.
5-
</card>
64

7-
<card>
8-
## Example {#example}
5+
## Example
96

107
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.
118

12-
~~~~
9+
```html
1310
<html>
1411
<body>
1512

@@ -32,7 +29,7 @@ In order to have the JavaScript SDK set a cookie containing a signed request (wh
3229
FB.init({
3330
appId: 'your-app-id',
3431
cookie: true, // This is important, it's not enabled by default
35-
version: 'v2.6'
32+
version: 'v2.8'
3633
});
3734
};
3835
@@ -46,16 +43,16 @@ In order to have the JavaScript SDK set a cookie containing a signed request (wh
4643
</script>
4744
</body>
4845
</html>
49-
~~~~
46+
```
5047

5148
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.
5249

53-
~~~~
50+
```php
5451
# /js-login.php
5552
$fb = new Facebook\Facebook([
5653
'app_id' => '{app-id}',
5754
'app_secret' => '{app-secret}',
58-
'default_graph_version' => 'v2.6',
55+
'default_graph_version' => 'v2.8',
5956
]);
6057

6158
$helper = $fb->getJavaScriptHelper();
@@ -86,5 +83,4 @@ $_SESSION['fb_access_token'] = (string) $accessToken;
8683
// User is logged in!
8784
// You can redirect them to a members-only page.
8885
//header('Location: https://example.com/members.php');
89-
~~~~
90-
</card>
86+
```

docs/examples/access_token_from_page_tab.md

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,16 @@
1-
<card>
21
# Get Access Token From Page Tab Example
32

43
This example covers obtaining an access token and signed request from within the context of a page tab with the Facebook SDK for PHP.
5-
</card>
64

7-
<card>
8-
## Example {#example}
5+
## Example
96

107
Page tabs behave much like the app canvas. The PHP SDK provides a helper for page tabs that delivers specific methods unique to page tabs.
118

12-
~~~~
9+
```php
1310
$fb = new Facebook\Facebook([
1411
'app_id' => '{app-id}',
1512
'app_secret' => '{app-secret}',
16-
'default_graph_version' => 'v2.6',
13+
'default_graph_version' => 'v2.8',
1714
]);
1815

1916
$helper = $fb->getPageTabHelper();
@@ -47,5 +44,4 @@ var_dump($helper->getSignedRequest());
4744

4845
echo '<h3>Access Token</h3>';
4946
var_dump($accessToken->getValue());
50-
~~~~
51-
</card>
47+
```

docs/examples/batch_request.md

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,16 @@
1-
<card>
21
# Batch Request Example
32

43
This example covers sending a batch request with the Facebook SDK for PHP.
5-
</card>
64

7-
<card>
8-
## Example {#example}
5+
## Example
96

107
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).
118

12-
~~~~
9+
```php
1310
$fb = new Facebook\Facebook([
1411
'app_id' => '{app-id}',
1512
'app_secret' => '{app-secret}',
16-
'default_graph_version' => 'v2.6',
13+
'default_graph_version' => 'v2.8',
1714
]);
1815

1916
// Since all the requests will be sent on behalf of the same user,
@@ -77,7 +74,7 @@ foreach ($responses as $key => $response) {
7774
echo "<hr />\n\n";
7875
}
7976
}
80-
~~~~
77+
```
8178

8279
There five requests being made in this batch requests.
8380

@@ -89,32 +86,27 @@ There five requests being made in this batch requests.
8986

9087
If the request was successful, the user should have a new status update similar to this:
9188

92-
~~~~
89+
```
9390
My name is Foo User.
9491
9592
I like this page: Facebook Developers.
9693
9794
My next 2 events are House Warming Party,Some Foo Event.
98-
~~~~
95+
```
9996

10097
It should also contain a response containing two photos from the user.
10198

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).
107100
108-
<card>
109-
## Multiple User Example {#multiple-user-example}
101+
## Multiple User Example
110102

111103
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.
112104

113-
~~~~
105+
```php
114106
$fb = new Facebook\Facebook([
115107
'app_id' => '{app-id}',
116108
'app_secret' => '{app-secret}',
117-
'default_graph_version' => 'v2.6',
109+
'default_graph_version' => 'v2.8',
118110
]);
119111

120112
$batch = [
@@ -148,5 +140,4 @@ foreach ($responses as $key => $response) {
148140
echo "<hr />\n\n";
149141
}
150142
}
151-
~~~~
152-
</card>
143+
```

docs/examples/batch_upload.md

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,18 @@
1-
<card>
21
# Batch File Upload Example
32

43
This example covers uploading files in a batch request with the Facebook SDK for PHP.
5-
</card>
64

7-
<card>
8-
## Example {#example}
5+
## Example
96

107
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.
118

129
The following example will upload two photos and one video.
1310

14-
~~~~
11+
```php
1512
$fb = new Facebook\Facebook([
1613
'app_id' => '{app-id}',
1714
'app_secret' => '{app-secret}',
18-
'default_graph_version' => 'v2.6',
15+
'default_graph_version' => 'v2.8',
1916
]);
2017

2118
// Since all the requests will be sent on behalf of the same user,
@@ -62,5 +59,4 @@ foreach ($responses as $key => $response) {
6259
echo "<hr />\n\n";
6360
}
6461
}
65-
~~~~
66-
</card>
62+
```

docs/examples/facebook_login.md

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,20 @@
1-
<card>
21
# Facebook Login Example
32

43
This example covers Facebook Login with the Facebook SDK for PHP.
5-
</card>
64

7-
<card>
8-
## Example {#example}
5+
## Example
96

107
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.
118

129
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`.
13-
</card>
1410

15-
<card>
16-
## /login.php {#login}
11+
## /login.php
1712

18-
~~~~
13+
```php
1914
$fb = new Facebook\Facebook([
2015
'app_id' => '{app-id}',
2116
'app_secret' => '{app-secret}',
22-
'default_graph_version' => 'v2.6',
17+
'default_graph_version' => 'v2.8',
2318
]);
2419

2520
$helper = $fb->getRedirectLoginHelper();
@@ -28,17 +23,15 @@ $permissions = ['email']; // Optional permissions
2823
$loginUrl = $helper->getLoginUrl('https://example.com/fb-callback.php', $permissions);
2924

3025
echo '<a href="' . $loginUrl . '">Log in with Facebook!</a>';
31-
~~~~
32-
</card>
26+
```
3327

34-
<card>
35-
## /fb-callback.php {#fbcallback}
28+
## /fb-callback.php
3629

37-
~~~~
30+
```php
3831
$fb = new Facebook\Facebook([
3932
'app_id' => '{app-id}',
4033
'app_secret' => '{app-secret}',
41-
'default_graph_version' => 'v2.6',
34+
'default_graph_version' => 'v2.8',
4235
]);
4336

4437
$helper = $fb->getRedirectLoginHelper();
@@ -105,5 +98,4 @@ $_SESSION['fb_access_token'] = (string) $accessToken;
10598
// User is logged in with a long-lived access token.
10699
// You can redirect them to a members-only page.
107100
//header('Location: https://example.com/members.php');
108-
~~~~
109-
</card>
101+
```

docs/examples/pagination_basic.md

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,18 @@
1-
<card>
21
# Pagination Example
32

43
This example covers basic cursor pagination with the Facebook SDK for PHP.
5-
</card>
64

7-
<card>
8-
## Example {#example}
5+
## Example
96

107
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.
118

129
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.
1310

14-
~~~~
11+
```php
1512
$fb = new Facebook\Facebook([
1613
'app_id' => '{app-id}',
1714
'app_secret' => '{app-secret}',
18-
'default_graph_version' => 'v2.6',
15+
'default_graph_version' => 'v2.8',
1916
]);
2017

2118
try {
@@ -44,5 +41,4 @@ $nextFeed = $fb->next($feedEdge);
4441
foreach ($nextFeed as $status) {
4542
var_dump($status->asArray());
4643
}
47-
~~~~
48-
</card>
44+
```

docs/examples/post_links.md

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,18 @@
1-
<card>
21
# Post Links Using the Graph API
32

43
This example covers posting a link to the current user's timeline using the Graph API and Facebook SDK for PHP.
54

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.
76

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).
108

11-
<card>
12-
## Example {#example}
9+
## Example
1310

14-
~~~~
11+
```php
1512
$fb = new Facebook\Facebook([
1613
'app_id' => '{app-id}',
1714
'app_secret' => '{app-secret}',
18-
'default_graph_version' => 'v2.6',
15+
'default_graph_version' => 'v2.8',
1916
]);
2017

2118
$linkData = [
@@ -37,7 +34,6 @@ try {
3734
$graphNode = $response->getGraphNode();
3835

3936
echo 'Posted with id: ' . $graphNode['id'];
40-
~~~~
37+
```
4138

4239
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).
43-
</card>

docs/examples/retrieve_user_profile.md

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,18 @@
1-
<card>
21
# Retrieve User Profile via the Graph API
32

43
This example covers getting profile information for the current user and printing their name, using the Graph API and the Facebook SDK for PHP.
54

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).
76

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).
108

11-
<card>
12-
## Example {#example}
9+
## Example
1310

14-
~~~~
11+
```php
1512
$fb = new Facebook\Facebook([
1613
'app_id' => '{app-id}',
1714
'app_secret' => '{app-secret}',
18-
'default_graph_version' => 'v2.6',
15+
'default_graph_version' => 'v2.8',
1916
]);
2017

2118
try {
@@ -34,5 +31,4 @@ $user = $response->getGraphUser();
3431
echo 'Name: ' . $user['name'];
3532
// OR
3633
// echo 'Name: ' . $user->getName();
37-
~~~~
38-
</card>
34+
```

0 commit comments

Comments
 (0)