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: CHANGELOG.md
-3Lines changed: 0 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,6 @@
2
2
3
3
Starting with version 5, the Facebook PHP SDK follows [SemVer](http://semver.org/).
4
4
5
-
6
5
## 5.x
7
6
8
7
Version 5 of the Facebook PHP SDK is a complete refactor of version 4. It comes loaded with lots of new features and a friendlier API.
@@ -87,12 +86,10 @@ Version 5 of the Facebook PHP SDK is a complete refactor of version 4. It comes
87
86
- Added `ext-mbstring` to composer require
88
87
- Added this CHANGELOG. Hi! :)
89
88
90
-
91
89
## 4.1-dev
92
90
93
91
Since the Facebook PHP SDK didn't follow SemVer in version 4.x, the master branch was going to be released as 4.1. However, the SDK switched to SemVer in v5.0. So any references on the internet to version 4.1 can be assumed to be an alias to version `5.0.0`
94
92
95
-
96
93
## 4.0.x
97
94
98
95
Version 4.0 of the Facebook PHP SDK did not follow [SemVer](http://semver.org/). The versioning format used was as follows: `4.MAJOR.(MINOR|PATCH)`. The `MINOR` and `PATCH` versions were squashed together.
Copy file name to clipboardExpand all lines: CONTRIBUTING.md
-3Lines changed: 0 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,7 +14,6 @@ The v5 (`5.x` branch) is maintained only for bug fixes, node/edge updates or doc
14
14
## Code of Conduct
15
15
The code of conduct is described in [`CODE_OF_CONDUCT.md`](CODE_OF_CONDUCT.md)
16
16
17
-
18
17
## Pull Requests
19
18
20
19
-**Sign the CLA** - For us to accept contributions you will have to first have signed the
@@ -38,14 +37,12 @@ The code of conduct is described in [`CODE_OF_CONDUCT.md`](CODE_OF_CONDUCT.md)
38
37
39
38
-**Ensure no coding standards violations** - Please [run PHP Code Sniffer](#running-php-code-sniffer) using the PSR-2 standard before submitting your pull request. A violation will cause the build to fail, so please make sure there are no violations. We can't accept a patch if the build fails.
40
39
41
-
42
40
## Running Tests
43
41
44
42
```bash
45
43
$ ./vendor/bin/phpunit
46
44
```
47
45
48
-
49
46
## Running PHP Code Sniffer
50
47
51
48
You can install [PHP Code Sniffer](https://github.com/squizlabs/PHP_CodeSniffer) globally with composer.
This repository contains the open source PHP SDK that allows you to access the Facebook Platform from your PHP app.
9
8
10
-
11
9
## Installation
12
10
13
11
The Facebook PHP SDK can be installed with [Composer](https://getcomposer.org/). Run this command:
@@ -16,13 +14,12 @@ The Facebook PHP SDK can be installed with [Composer](https://getcomposer.org/).
16
14
composer require facebook/graph-sdk
17
15
```
18
16
19
-
Please be aware, that there are issues when using the Facebook SDK together with [Guzzle](https://github.com/guzzle/guzzle) 6.x. php-graph-sdk v5.x only works with Guzzle 5.x out of the box. However, [there is a workaround to make it work with Guzzle 6.x](https://www.sammyk.me/how-to-inject-your-own-http-client-in-the-facebook-php-sdk-v5#writing-a-guzzle-6-http-client-implementation-from-scratch).
17
+
Please be aware, that there are issues when using the Facebook SDK together with [Guzzle](https://github.com/guzzle/guzzle) 6.x. php-graph-sdk v5.x only works with Guzzle 5.x out of the box. However, [there is a workaround to make it work with Guzzle 6.x](https://www.sammyk.me/how-to-inject-your-own-http-client-in-the-facebook-php-sdk-v5#writing-a-guzzle-6-http-client-implementation-from-scratch).
20
18
21
19
## Upgrading to v5.x
22
20
23
21
Upgrading from v4.x? Facebook PHP SDK v5.x introduced breaking changes. Please [read the upgrade guide](https://www.sammyk.me/upgrading-the-facebook-php-sdk-from-v4-to-v5) before upgrading.
24
22
25
-
26
23
## Usage
27
24
28
25
> **Note:** This version of the Facebook SDK for PHP requires PHP 5.4 or greater.
@@ -65,7 +62,6 @@ echo 'Logged in as ' . $me->getName();
65
62
66
63
Complete documentation, installation instructions, and examples are available [here](docs/).
67
64
68
-
69
65
## Tests
70
66
71
67
1.[Composer](https://getcomposer.org/) is a prerequisite for running the tests. Install composer globally, then run `composer install` to install required files.
@@ -82,17 +78,14 @@ By default the tests will send live HTTP requests to the Graph API. If you are w
For us to accept contributions you will have to first have signed the [Contributor License Agreement](https://developers.facebook.com/opensource/cla). Please see [CONTRIBUTING](https://github.com/facebook/php-graph-sdk/blob/master/CONTRIBUTING.md) for details.
89
84
90
-
91
85
## License
92
86
93
87
Please see the [license file](https://github.com/facebook/php-graph-sdk/blob/master/LICENSE) for more information.
94
88
95
-
96
89
## Security Vulnerabilities
97
90
98
91
If you have found a security issue, please contact the maintainers directly at [me@sammyk.me](mailto:me@sammyk.me).
The autoloader should be able to auto-detect the proper location of the source code.
52
51
53
-
54
52
### Keeping things tidy
55
53
56
54
The source code includes myriad files that aren't necessary for use in a production environment. If you'd like to strip out everything except the core files, follow this example.
@@ -102,7 +100,6 @@ The SDK can be used to support logging a Facebook user into your site using Face
102
100
103
101
Most all request made to the Graph API require an access token. We can obtain user access tokens with the SDK using the [helper classes](reference.md).
104
102
105
-
106
103
### Obtaining an access token from redirect
107
104
108
105
For most websites, you'll use the [`Facebook\Helpers\FacebookRedirectLoginHelper`](reference/FacebookRedirectLoginHelper.md) to generate a login URL with the `getLoginUrl()` method. The link will take the user to an app authorization screen and upon approval, will redirect them back to a URL that you specified. On the redirect callback page we can obtain the user access token as an [`AccessToken`](reference/AccessToken.md) entity.
@@ -148,7 +145,6 @@ if (isset($accessToken)) {
148
145
}
149
146
```
150
147
151
-
152
148
### Obtaining an access token from a Facebook Canvas context
153
149
154
150
If your app is on Facebook Canvas, use the `getAccessToken()` method on [`Facebook\Helpers\FacebookCanvasHelper`](reference/FacebookCanvasHelper.md) to get an [`AccessToken`](reference/AccessToken.md) entity for the user.
@@ -179,7 +175,6 @@ if (isset($accessToken)) {
179
175
180
176
> If your app exists within the context of a Page tab, you can obtain an access token using the example above since a Page tab is very similar to a Facebook Canvas app. But if you'd like to use a Page-tab-specific helper, you can use the [`Facebook\Helpers\FacebookPageTabHelper`](reference/FacebookPageTabHelper.md)
181
177
182
-
183
178
### Obtaining an access token from the SDK for JavaScript
184
179
185
180
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.
Copy file name to clipboardExpand all lines: docs/reference.md
-3Lines changed: 0 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -34,7 +34,6 @@ These classes are used in a Graph API request/response cycle.
34
34
|[`Facebook\FacebookBatchResponse`](reference/FacebookBatchResponse.md)| An entity that represents an HTTP response from Graph after sending a batch request. |
35
35
|[`Facebook\FacebookClient`](reference/FacebookClient.md)| A service object that sends HTTP requests and receives HTTP responses to and from the Graph API. |
36
36
37
-
38
37
# Signed Requests
39
38
40
39
Classes to help obtain and manage signed requests.
@@ -55,7 +54,6 @@ These are the core exceptions that the SDK will throw when an error occurs.
55
54
|[`Facebook\Exceptions\FacebookSDKException`](reference/FacebookSDKException.md)| The base exception to all exceptions thrown by the SDK. Thrown when there is a non-Graph-response-related error. |
56
55
|[`Facebook\Exceptions\FacebookResponseException`](reference/FacebookResponseException.md)| The base exception to all Graph error responses. This exception is never thrown directly. |
57
56
58
-
59
57
# Graph Nodes and Edges
60
58
61
59
Graph nodes are collections that represent nodes returned by the Graph API. And Graph edges are a collection of nodes returned from an edge on the Graph API.
@@ -71,7 +69,6 @@ Graph nodes are collections that represent nodes returned by the Graph API. And
71
69
|[`Facebook\GraphNodes\GraphPicture`](reference/GraphNode.md#graphpicture-instance-methods)| A collection that represents a Picture node. |
72
70
|[`Facebook\GraphNodes\GraphUser`](reference/GraphNode.md#graphuser-instance-methods)| A collection that represents a User node. |
73
71
74
-
75
72
# File Uploads
76
73
77
74
These are entities that represent files to be uploaded with a Graph request.
Copy file name to clipboardExpand all lines: docs/reference/FacebookRedirectLoginHelper.md
-4Lines changed: 0 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,6 @@ The most commonly used helper is the `FacebookRedirectLoginHelper` which allows
6
6
7
7
Facebook Login is achieved via OAuth 2.0. But you don't really have to know much about OAuth 2.0 since the SDK for PHP does all the heavy lifting for you.
8
8
9
-
10
9
### Obtaining an instance of FacebookRedirectLoginHelper
11
10
12
11
You can obtain an instance of the `FacebookRedirectLoginHelper` from the `getRedirectLoginHelper()` method on the `Facebook\Facebook` service.
@@ -116,19 +115,16 @@ If no authorization code could be found from the `code` param in the URL, this m
116
115
117
116
The `FacebookRedirectLoginHelper` has to orchestrate a number of components from the hosting environment to make the OAuth 2.0 authorization process as easy as possible to integrate. Out of the box it auto-detects all the things it needs, but sometimes you'll want to control these components.
118
117
119
-
120
118
### Sessions (persistent data)
121
119
122
120
In order to prevent [CSRF](http://en.wikipedia.org/wiki/Cross-site_request_forgery)'s, a unique value is generated with each login link and stored in a session.
123
121
124
122
Most modern web frameworks have custom session handlers that allow you to manage your sessions with something other than the default flat-file storage. You can integrate your framework's custom session handling by coding to the [`PersistentDataInterface`](PersistentDataInterface.md).
125
123
126
-
127
124
### CSPRNG
128
125
129
126
The CSRF value that the `getLoginUrl()`, `getReRequestUrl()`, and `getReAuthenticationUrl()` methods generate are all _cryptographically secure_ random strings. PHP's native support of CSPRNG's is spotty at best. The PHP SDK goes to great lengths to to detect a suitable CSPRNG but in rare cases, it might not find a suitable one. The [`PseudoRandomStringGeneratorInterface`](PseudoRandomStringGeneratorInterface.md) allows you to inject your own custom CSPRNG.
130
127
131
-
132
128
### URL detection
133
129
134
130
In order to not make you pass the callback URL to the `getAccessToken()` method, the SDK will do its best to detect the callback's URL for you. Most modern web frameworks have URL detection built-in. You can code your specific web framework's URL detection logic by coding to the [`UrlDetectionInterface`](UrlDetectionInterface.md).
Copy file name to clipboardExpand all lines: docs/reference/GraphNode.md
+1-8Lines changed: 1 addition & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -63,29 +63,24 @@ $total = count($graphNode);
63
63
64
64
## GraphNode Instance Methods
65
65
66
-
67
66
### asArray
68
-
`asArray()`
67
+
`asArray()`
69
68
Returns the raw representation (associative arrays, nested) of the node's underlying data.
70
69
71
-
72
70
### asJson
73
71
`asJson()`
74
72
Returns the data as a JSON string.
75
73
76
-
77
74
### getField
78
75
`getField(string $name, string $default = 'foo')`
79
76
Gets the value from the field of a Graph node. If the value is a scalar (string, number, etc.) it will be returned. If it's an associative array, it will be returned as a GraphNode.
80
77
81
78
The second argument lets you define a default value to return if the field doesn't exist.
82
79
83
-
84
80
### getFieldNames
85
81
`getFieldNames()`
86
82
Returns an array with the names of all fields present on the graph node.
87
83
88
-
89
84
### map
90
85
`map(Closure $callback)`
91
86
Provides a way to map over the data within the collection just like `array_map()`.
@@ -180,7 +175,6 @@ The following properties on the `GraphPage` collection will get automatically ca
0 commit comments