Skip to content

Commit

Permalink
Killed entities folder
Browse files Browse the repository at this point in the history
  • Loading branch information
SammyK committed Dec 13, 2014
1 parent 564f527 commit 63b1bca
Show file tree
Hide file tree
Showing 55 changed files with 230 additions and 242 deletions.
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ As you may have already noticed, the Facebook SDK v4 does not follow strict [sem
- Moved response collection objects to `GraphNodes\*` directory
- Moved helpers to `Helpers\*` directory
- Moved `FacebookRequest` and `FacebookResponse` to `Entities\*` directory
- Killed `FacebookSession` in favor of `Facebook\Entities\AccessToken`
- Killed `FacebookSession` in favor of `Facebook\AccessToken`
- Added `FacebookClient` service
- Renamed `FacebookRequestException` to `FacebookResponseException`
- Renamed `FacebookHttpable` to `FacebookHttpClientInterface`
Expand All @@ -21,7 +21,7 @@ As you may have already noticed, the Facebook SDK v4 does not follow strict [sem
- Added support for "rerequest" authorization
- [`AccessToken`] Added serialization support
- Added `ext-mbstring` to composer require
- Added `Facebook\Entities\FacebookApp` entity
- Added `Facebook\FacebookApp` entity
- Namespaced tests
- Grouped functional tests under `functional` group
- Added `Facebook\Facebook` super service
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ $fb = new Facebook\Facebook([
//'default_access_token' => '{access-token}', // optional
]);

// Use one of the helper classes to get a Facebook\Entities\AccessToken entity.
// Use one of the helper classes to get a Facebook\AccessToken entity.
// $helper = $fb->getRedirectLoginHelper();
// $helper = $fb->getJavaScriptHelper();
// $helper = $fb->getCanvasHelper();
Expand Down
44 changes: 22 additions & 22 deletions docs/Facebook.fbmd
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ The ID of your Facebook app (required).
The secret of your Facebook app (required).

### `default_access_token`
The default fallback access token to use if one is not explicitly provided. The value can be of type `string` or `Facebook\Entities\AccessToken`. If any other value is provided an `InvalidArgumentException` will be thrown. Defaults to `null`.
The default fallback access token to use if one is not explicitly provided. The value can be of type `string` or `Facebook\AccessToken`. If any other value is provided an `InvalidArgumentException` will be thrown. Defaults to `null`.

### `enable_beta_mode`
Enable [beta mode](https://developers.facebook.com/docs/support/beta-tier/) so that request are made to the [https://graph.beta.facebook.com](https://graph.beta.facebook.com/) endpoint. Set to boolean `true` to enable or `false` to disable. Defaults to `false`.
Expand Down Expand Up @@ -163,7 +163,7 @@ $fb = new Facebook\Facebook();
~~~~
public FacebookApp getApp()
~~~~
Returns the instance of `Facebook\Entities\FacebookApp` for the instantiated service.
Returns the instance of `Facebook\FacebookApp` for the instantiated service.
</card>

<card>
Expand All @@ -177,34 +177,34 @@ Returns the instance of [`Facebook\FacebookClient`](/docs/php/FacebookClient) fo
<card>
### getLastResponse() {#get-last-response}
~~~~
public Facebook\Entities\FacebookResponse|Facebook\Entities\FacebookBatchResponse|null getLastResponse()
public Facebook\FacebookResponse|Facebook\FacebookBatchResponse|null getLastResponse()
~~~~
Returns the last response received from the Graph API in the form of a `Facebook\Entities\FacebookResponse` or `Facebook\Entities\FacebookBatchResponse`.
Returns the last response received from the Graph API in the form of a `Facebook\FacebookResponse` or `Facebook\FacebookBatchResponse`.
</card>

<card>
### getDefaultAccessToken() {#get-default-access-token}
~~~~
public Facebook\Entities\AccessToken|null getDefaultAccessToken()
public Facebook\AccessToken|null getDefaultAccessToken()
~~~~

Returns the default fallback `Facebook\Entities\AccessToken` entity that is being used with every request to Graph. This value can be set with the configuration option `default_access_token` or by using `setDefaultAccessToken()`.
Returns the default fallback `Facebook\AccessToken` entity that is being used with every request to Graph. This value can be set with the configuration option `default_access_token` or by using `setDefaultAccessToken()`.
</card>

<card>
### setDefaultAccessToken() {#set-default-access-token}
~~~~
public setDefaultAccessToken(string|Facebook\Entities\AccessToken $accessToken)
public setDefaultAccessToken(string|Facebook\AccessToken $accessToken)
~~~~

Sets the default access token to be use with all requests sent to Graph. The access token can be in string or `Facebook\Entities\AccessToken` format.
Sets the default access token to be use with all requests sent to Graph. The access token can be in string or `Facebook\AccessToken` format.

~~~~
$fb->setDefaultAccessToken('{my-access-token}');

// . . . OR . . .

$accessToken = new Facebook\Entities\AccessToken('{my-access-token}');
$accessToken = new Facebook\AccessToken('{my-access-token}');
$fb->setDefaultAccessToken($accessToken);
~~~~

Expand All @@ -222,15 +222,15 @@ Returns the default version of Graph. If the `default_graph_version` configurati
<card>
### get() {#get}
~~~~
public Facebook\Entities\FacebookResponse get(
public Facebook\FacebookResponse get(
string $endpoint,
string|AccessToken|null $accessToken,
string|null $eTag,
string|null $graphVersion
)
~~~~

Sends a GET request to Graph and returns a `Facebook\Entities\FacebookResponse`.
Sends a GET request to Graph and returns a `Facebook\FacebookResponse`.

`$endpoint`
The url to send to Graph without the version prefix (required).
Expand All @@ -240,7 +240,7 @@ $fb->get('/me');
~~~

`$accessToken`
The access token (as a `string` or `Facebook\Entities\AccessToken`) to use for the request. If none is provided, the SDK will assume the value from the `default_access_token` configuration option if it was set.
The access token (as a `string` or `Facebook\AccessToken`) to use for the request. If none is provided, the SDK will assume the value from the `default_access_token` configuration option if it was set.

`$eTag`
[Graph supports eTags](https://developers.facebook.com/docs/reference/ads-api/etags-reference/). Set this to the eTag from a previous request to get a `304 Not Modified` response if the data has not changed.
Expand All @@ -252,7 +252,7 @@ Set the Graph version to something other than what was set in the `default_graph
<card>
### post() {#post}
~~~~
public Facebook\Entities\FacebookResponse post(
public Facebook\FacebookResponse post(
string $endpoint,
array $params,
string|AccessToken|null $accessToken,
Expand All @@ -261,7 +261,7 @@ public Facebook\Entities\FacebookResponse post(
)
~~~~

Sends a POST request to Graph and returns a `Facebook\Entities\FacebookResponse`.
Sends a POST request to Graph and returns a `Facebook\FacebookResponse`.

The arguments are the same as `get()` above with the exception of `$params`.

Expand All @@ -276,15 +276,15 @@ $response = $fb->post('/me/feed', ['message' => 'Foo message']);
<card>
### delete() {#delete}
~~~~
public Facebook\Entities\FacebookResponse delete(
public Facebook\FacebookResponse delete(
string $endpoint,
string|AccessToken|null $accessToken,
string|null $eTag,
string|null $graphVersion
)
~~~~

Sends a DELETE request to Graph and returns a `Facebook\Entities\FacebookResponse`.
Sends a DELETE request to Graph and returns a `Facebook\FacebookResponse`.

The arguments are the same as `get()` above.

Expand All @@ -296,7 +296,7 @@ $response = $fb->delete('/{node-id}');
<card>
### request() {#request}
~~~~
public Facebook\Entities\FacebookRequest request(
public Facebook\FacebookRequest request(
string $method,
string $endpoint,
array $params,
Expand All @@ -306,7 +306,7 @@ public Facebook\Entities\FacebookRequest request(
)
~~~~

Instantiates a new `Facebook\Entities\FacebookRequest` entity **but does not send the request to Graph**. This is useful for creating a number of requests to be sent later in a batch request (see `sendBatchRequest()` below).
Instantiates a new `Facebook\FacebookRequest` entity **but does not send the request to Graph**. This is useful for creating a number of requests to be sent later in a batch request (see `sendBatchRequest()` below).

The arguments are the same as `post()` above with the exception of `$method`.

Expand All @@ -321,7 +321,7 @@ $request = $fb->request('GET', '/{node-id}');
<card>
### sendRequest() {#send-request}
~~~~
public Facebook\Entities\FacebookResponse sendRequest(
public Facebook\FacebookResponse sendRequest(
string $method,
string $endpoint,
array $params,
Expand All @@ -341,19 +341,19 @@ $response = $fb->sendRequest('GET', '/me', [], '{access-token}', 'eTag', 'v2.2')
<card>
### sendBatchRequest() {#send-batch-request}
~~~~
public Facebook\Entities\FacebookBatchResponse sendBatchRequest(
public Facebook\FacebookBatchResponse sendBatchRequest(
array $requests,
string|AccessToken|null $accessToken,
string|null $graphVersion
)
~~~~

Sends an array of `Facebook\Entities\FacebookRequest` entities as a batch request to Graph.
Sends an array of `Facebook\FacebookRequest` entities as a batch request to Graph.

The `$accessToken` and `$graphVersion` arguments are the same as `get()` above.

`$requests`
An array of `Facebook\Entities\FacebookRequest` entities. This can be a numeric or associative array but every value of the array has to be of type `Facebook\Entities\FacebookRequest`.
An array of `Facebook\FacebookRequest` entities. This can be a numeric or associative array but every value of the array has to be of type `Facebook\FacebookRequest`.

If the requests are sent as an associative array, the key will be used as the `name` of the request so that it can be referenced by another request. See more on [batch request naming and using JSONPath](https://developers.facebook.com/docs/graph-api/making-multiple-requests/#operations).

Expand Down
20 changes: 10 additions & 10 deletions docs/FacebookApp.fbmd
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
<card>
# FacebookApp for the Facebook SDK for PHP

In order to make requests to the Graph API, you need to [create a Facebook app](https://developers.facebook.com/apps) and obtain the app ID and the app secret. The `Facebook\Entities\FacebookApp` entity represents the Facebook app that is making the requests to the Graph API.
In order to make requests to the Graph API, you need to [create a Facebook app](https://developers.facebook.com/apps) and obtain the app ID and the app secret. The `Facebook\FacebookApp` entity represents the Facebook app that is making the requests to the Graph API.
</card>

<card>
## Facebook\Entities\FacebookApp {#overview}
## Facebook\FacebookApp {#overview}

To instantiate a new `Facebook\Entities\FacebookApp` entity, pass the app ID and app secret to the constructor.
To instantiate a new `Facebook\FacebookApp` entity, pass the app ID and app secret to the constructor.

~~~~
$fbApp = new Facebook\Entities\FacebookApp('{app-id}', '{app-secret}');
$fbApp = new Facebook\FacebookApp('{app-id}', '{app-secret}');
~~~~

Alternatively you can obtain the `Facebook\Entities\FacebookApp` entity from the [`Facebook\Facebook`](/docs/php/Facebook) super service class.
Alternatively you can obtain the `Facebook\FacebookApp` entity from the [`Facebook\Facebook`](/docs/php/Facebook) super service class.

~~~~
$fb = new Facebook\Facebook([/* . . . */]);
Expand All @@ -28,9 +28,9 @@ In the most common cases, you'll rarely be using the `FacebookApp` entity direct

### getAccessToken() {#get-access-token}
~~~~
public Facebook\Entities\AccessToken getAccessToken()
public Facebook\AccessToken getAccessToken()
~~~~
Returns an app access token in the form of a [`Facebook\Entities\AccessToken`](/docs/php/AccessToken) entity.
Returns an app access token in the form of a [`Facebook\AccessToken`](/docs/php/AccessToken) entity.
</card>

<card>
Expand All @@ -52,13 +52,13 @@ Returns an the app secret.
<card>
## Serialization {#serialization}

The `Facebook\Entities\FacebookApp` entity implements the `\Serializable` interface so it can be serialized and unserialized.
The `Facebook\FacebookApp` entity implements the `\Serializable` interface so it can be serialized and unserialized.

~~~~
$fbApp = new Facebook\Entities\FacebookApp('foo-app-id', 'foo-app-secret');
$fbApp = new Facebook\FacebookApp('foo-app-id', 'foo-app-secret');

$serializedFacebookApp = serialize($fbApp);
// C:29:"Facebook\\Entities\\FacebookApp":54:{a:2:{i:0;s:10:"foo-app-id";i:1;s:14:"foo-app-secret";}}
// C:29:"Facebook\\FacebookApp":54:{a:2:{i:0;s:10:"foo-app-id";i:1;s:14:"foo-app-secret";}}

$unserializedFacebookApp = unserialize($serializedFacebookApp);
echo $unserializedFacebookApp->getAccessToken();
Expand Down
30 changes: 15 additions & 15 deletions docs/FacebookBatchRequest.fbmd
Original file line number Diff line number Diff line change
Expand Up @@ -5,34 +5,34 @@ Represents a batch request that will be sent to the Graph API.
</card>

<card>
## Facebook\Entities\FacebookBatchRequest {#overview}
## Facebook\FacebookBatchRequest {#overview}

You can instantiate a new `FacebookBatchRequest` entity directly by sending the arguments to the constructor.

~~~~
use Facebook\Entities\FacebookBatchRequest;
use Facebook\FacebookBatchRequest;

$request = new FacebookBatchRequest(
Facebook\Entities\FacebookApp $app,
Facebook\FacebookApp $app,
array $requests,
string|null $accessToken,
string|null $graphVersion
);
~~~~

The `$requests` array is an array of [`Facebook\Entities\FacebookRequest`'s](/docs/php/FacebookRequest) to be sent as a batch request.
The `$requests` array is an array of [`Facebook\FacebookRequest`'s](/docs/php/FacebookRequest) to be sent as a batch request.

The `FacebookBatchRequest` entity does not actually make any calls to the Graph API, but instead just represents a batch request that can be sent to the Graph API later. The batch request can be sent by using [`Facebook\Facebook::sendBatchRequest()`](/docs/php/Facebook#send-batch-request) or [`Facebook\FacebookClient::sendBatchRequest()`](/docs/php/FacebookClient#send-batch-request).

Usage:

~~~~
$fbApp = new Facebook\Entities\FacebookApp('{app-id}', '{app-secret}');
$fbApp = new Facebook\FacebookApp('{app-id}', '{app-secret}');
$requests = [
new Facebook\Entities\FacebookRequest(/* */),
new Facebook\Entities\FacebookRequest(/* */),
new Facebook\FacebookRequest(/* */),
new Facebook\FacebookRequest(/* */),
];
$batchRequest = new Facebook\Entities\FacebookBatchRequest($fbApp, $requests, '{access-token}');
$batchRequest = new Facebook\FacebookBatchRequest($fbApp, $requests, '{access-token}');

// Send the batch request to Graph
try {
Expand Down Expand Up @@ -82,16 +82,16 @@ foreach ($batchResponse as $key => $response) {
<card>
## Instance Methods {#instance-methods}

Since the `Facebook\Entities\FacebookBatchRequest` is extended from the [`Facebook\Entities\FacebookRequest`](/docs/php/FacebookRequest) entity, all the methods are inherited.
Since the `Facebook\FacebookBatchRequest` is extended from the [`Facebook\FacebookRequest`](/docs/php/FacebookRequest) entity, all the methods are inherited.

### add() {#add}
~~~~
public add(
array|Facebook\Entities\FacebookBatchRequest $request,
array|Facebook\FacebookBatchRequest $request,
string|null $name
)
~~~~
Adds a request to be sent in the batch request. The `$request` can be a single [`Facebook\Entities\FacebookRequest`](/docs/php/FacebookRequest) or an array of `Facebook\Entities\FacebookRequest`'s.
Adds a request to be sent in the batch request. The `$request` can be a single [`Facebook\FacebookRequest`](/docs/php/FacebookRequest) or an array of `Facebook\FacebookRequest`'s.

The `$name` argument is optional and is used to identify the request in the batch.
</card>
Expand All @@ -101,27 +101,27 @@ The `$name` argument is optional and is used to identify the request in the batc
~~~~
public array getRequests()
~~~~
Returns the array of [`Facebook\Entities\FacebookRequest`'s](/docs/php/FacebookRequest) to be sent in the batch request.
Returns the array of [`Facebook\FacebookRequest`'s](/docs/php/FacebookRequest) to be sent in the batch request.
</card>

<card>
## Array Access {#array-access}

Since `Facebook\Entities\FacebookBatchRequest` implements `\IteratorAggregate` and `\ArrayAccess`, the requests can be accessed via array syntax and can also be iterated over.
Since `Facebook\FacebookBatchRequest` implements `\IteratorAggregate` and `\ArrayAccess`, the requests can be accessed via array syntax and can also be iterated over.

~~~~
$fb = new Facebook\Facebook(/* . . . */);
$requests = [
'foo' => $fb->request('GET', '/me'),
'bar' => $fb->request('POST', '/me/feed', [/* */]),
];
$batchRequest = new Facebook\Entities\FacebookBatchRequest($fb->getApp(), $requests, '{access-token}');
$batchRequest = new Facebook\FacebookBatchRequest($fb->getApp(), $requests, '{access-token}');

var_dump($batchRequest[0]);
/*
array(2) {
'name' => string(3) "foo"
'request' => class Facebook\Entities\FacebookRequest
'request' => class Facebook\FacebookRequest
. . .
*/
~~~~
Expand Down
14 changes: 7 additions & 7 deletions docs/FacebookBatchResponse.fbmd
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ Represents a batch response returned from the Graph API.
</card>

<card>
## Facebook\Entities\FacebookBatchResponse {#overview}
## Facebook\FacebookBatchResponse {#overview}

After sending a batch request to the Graph API, the response will be returned in the form of a `Facebook\Entities\FacebookBatchResponse` entity.
After sending a batch request to the Graph API, the response will be returned in the form of a `Facebook\FacebookBatchResponse` entity.

Usage:

Expand Down Expand Up @@ -41,26 +41,26 @@ foreach ($batchResponse as $key => $response) {
}

var_dump($batchResponse);
// class Facebook\Entities\FacebookBatchResponse . . .
// class Facebook\FacebookBatchResponse . . .
~~~~
</card>

<card>
## Instance Methods {#instance-methods}

Since the `Facebook\Entities\FacebookBatchResponse` is extended from the [`Facebook\Entities\FacebookResponse`](/docs/php/FacebookResponse) entity, all the methods are inherited.
Since the `Facebook\FacebookBatchResponse` is extended from the [`Facebook\FacebookResponse`](/docs/php/FacebookResponse) entity, all the methods are inherited.

### getResponses() {#get-responses}
~~~~
public array getResponses()
~~~~
Returns the array of [`Facebook\Entities\FacebookResponse`](/docs/php/FacebookResponse) entities that were returned from Graph.
Returns the array of [`Facebook\FacebookResponse`](/docs/php/FacebookResponse) entities that were returned from Graph.
</card>

<card>
## Array Access {#array-access}

Since `Facebook\Entities\FacebookBatchResponse` implements `\IteratorAggregate` and `\ArrayAccess`, the responses can be accessed via array syntax and can also be iterated over.
Since `Facebook\FacebookBatchResponse` implements `\IteratorAggregate` and `\ArrayAccess`, the responses can be accessed via array syntax and can also be iterated over.

~~~~
$requests = [
Expand All @@ -79,6 +79,6 @@ foreach ($batchResponse as $key => $response) {
}

var_dump($batchResponse['foo']);
// class Facebook\Entities\FacebookResponse . . .
// class Facebook\FacebookResponse . . .
~~~~
</card>
Loading

0 comments on commit 63b1bca

Please sign in to comment.