Skip to content

Commit fc9cfa1

Browse files
nayafiaSammyK
nayafia
authored andcommitted
add syntax highlighting
1 parent 6897150 commit fc9cfa1

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

Diff for: docs/getting_started.md

+13-13
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ There are two methods to install the Facebook SDK for PHP. The recommended insta
2222

2323
[Composer](https://getcomposer.org/) is the recommended way to install the Facebook SDK for PHP. Simply run the following in the root of your project.
2424

25-
```
25+
```php
2626
composer require facebook/php-sdk-v4
2727

2828
> content: "The Facebook SDK starting adhering to [SemVer](http://semver.org/) with version 5. Previous to version 5, the SDK did not follow SemVer.",
@@ -34,7 +34,7 @@ Once you do this, composer will edit your `composer.json` file and download the
3434

3535
Make sure to include the Composer autoloader at the top of your script.
3636

37-
```
37+
```php
3838
require_once __DIR__ . '/vendor/autoload.php';
3939
```
4040

@@ -51,7 +51,7 @@ First, download the source code and unzip it wherever you like in your project.
5151

5252
Then include the autoloader provided in the SDK at the top of your script.
5353

54-
```
54+
```php
5555
require_once __DIR__ . '/path/to/facebook-php-sdk-v4/src/Facebook/autoload.php';
5656
```
5757

@@ -73,13 +73,13 @@ The path the the core SDK files should now be located in `/var/html/facebook-sdk
7373

7474
Assuming we have a script called `index.php` in the root of our web project, we need to include the autoloader at the top of our script.
7575

76-
```
76+
```php
7777
require_once __DIR__ . '/facebook-sdk-v5/autoload.php';
7878
```
7979

8080
If the autoloader is having trouble detecting the path to the source files, we can define the location of the source code before the `require_once` statement.
8181

82-
```
82+
```php
8383
define('FACEBOOK_SDK_V4_SRC_DIR', __DIR__ . '/facebook-sdk-v5/');
8484
require_once __DIR__ . '/facebook-sdk-v5/autoload.php';
8585
```
@@ -91,7 +91,7 @@ require_once __DIR__ . '/facebook-sdk-v5/autoload.php';
9191
9292
Before we can send requests to the Graph API, we need to load our app configuration into the `Facebook\Facebook` service.
9393

94-
```
94+
```php
9595
$fb = new Facebook\Facebook([
9696
'app_id' => '{app-id}',
9797
'app_secret' => '{app-secret}',
@@ -120,7 +120,7 @@ For most websites, you'll use the [`Facebook\Helpers\FacebookRedirectLoginHelper
120120
> content: "For this example we'll assume `login.php` will present the login link and the user will be redirected to `login-callback.php` where we will obtain the access token.",
121121
> type: 'info',
122122
123-
```
123+
```php
124124
# login.php
125125
$fb = new Facebook\Facebook([/* . . . */]);
126126

@@ -134,7 +134,7 @@ echo '<a href="' . $loginUrl . '">Log in with Facebook!</a>';
134134
> content: "The `FacebookRedirectLoginHelper` makes use of sessions to store a [CSRF](http://en.wikipedia.org/wiki/Cross-site_request_forgery) value. You need to make sure you have sessions enabled before invoking the `getLoginUrl()` method. This is usually done automatically in most web frameworks, but if you're not using a web framework you can add [`session_start();`](http://php.net/session_start) to the top of your `login.php` & `login-callback.php` scripts.",
135135
> type: 'warning',
136136
137-
```
137+
```php
138138
# login-callback.php
139139
$fb = new Facebook\Facebook([/* . . . */]);
140140

@@ -168,7 +168,7 @@ If your app is on Facebook Canvas, use the `getAccessToken()` method on [`Facebo
168168
> content: "The `FacebookCanvasHelper` will detect a [signed request](reference.md#signed-requests) for you and attempt to obtain an access token using the payload data from the signed request. The signed request will only contain the data needed to obtain an access token if the user has already authorized your app sometime in the past. If they have not yet authorized your app the `getAccessToken()` will return `null` and you will need to log the user in with either the [redirect method](#authentication-redirect) or by using the [SDK for JavaScript](https://developers.facebook.com/docs/javascript) and then use the SDK for PHP to [obtain the access token from the cookie](#authentication-javascript) the SDK for JavaScript set.",
169169
> type: 'warning',
170170
171-
```
171+
```php
172172
# example-canvas-app.php
173173
$fb = new Facebook\Facebook([/* . . . */]);
174174

@@ -198,7 +198,7 @@ if (isset($accessToken)) {
198198

199199
If you're already using the Facebook SDK for JavaScript to authenticate users, you can obtain the access token with PHP by using the [FacebookJavaScriptHelper](reference/FacebookJavaScriptHelper.md). The `getAccessToken()` method will return an [`AccessToken`](reference/AccessToken.md) entity.
200200

201-
```
201+
```php
202202
# example-obtain-from-js-cookie-app.php
203203
$fb = new Facebook\Facebook([/* . . . */]);
204204

@@ -229,7 +229,7 @@ When a user first logs into your app, the access token your app receives will be
229229

230230
To extend an access token, you can make use of the [`OAuth2Client`](reference/Facebook.md#getoauth2client).
231231

232-
```
232+
```php
233233
// OAuth 2.0 client handler
234234
$oAuth2Client = $fb->getOAuth2Client();
235235

@@ -245,7 +245,7 @@ Once you have an instance of the `Facebook\Facebook` service and obtained an acc
245245

246246
In this example we will send a GET request to the Graph API endpoint `/me`. The `/me` endpoint is a special alias to the [user node endpoint](https://developers.facebook.com/docs/graph-api/reference/user) that references the user or Page making the request.
247247

248-
```
248+
```php
249249
$fb = new Facebook\Facebook([/* . . . */]);
250250

251251
// Sets the default fallback access token so we don't have to pass it to each request
@@ -273,7 +273,7 @@ To get the response in the form of a nifty collection, we call `getGraphUser()`
273273

274274
If you don't care about fancy collections and just want the response as a plain-old array, you can call the `getDecodedBody()` method on the `FacebookResponse` entity.
275275

276-
```
276+
```php
277277
try {
278278
$response = $fb->get('/me');
279279
} catch(Facebook\Exceptions\FacebookSDKException $e) {

0 commit comments

Comments
 (0)