facebook/facebook-php-sdk-v4 — pull request #245 by SammyK (2014-10-09 08:38:03+00:00)
Title: [4.1] Added Facebook super service class

Hey guys! How have you been? :)

So since momentum on 4.1 slowed down a bit I thought I'd post a first draft of the `Facebook\Facebook` super service class. This ties all the major elements of the SDK together to make it as crazy-simple to use as possible.

```php
use Facebook\Facebook;

$fb = new Facebook([
'app_id' => $config['app_id'],
'app_secret' => $config['app_secret'],
'default_access_token' => $config['access_token'], // optional
]);

// Get a user
$response = $fb->get('/me')->getGraphUser();

// Post to user timeline
$response = $fb->post('/me/feed', ['message' => 'Foo message']);

// Delete a node
$response = $fb->delete('/{node-id}');
```

If you don't provide a `default_access_token`, you'll need to pass it in the method that makes the requests.

```php
$res = $fb->get('/me', '{access-token}');
$res = $fb->post('/me/feed', ['foo' => 'bar'], '{access-token}');
$res = $fb->delete('/{node-id}', '{access-token}');
```

Here's a full list of config options you can pass to the `Facebook\Facebook` super service class in this first draft:

```php
$fb = new Facebook([
// The Facebook app ID
'app_id' => '{app-id}',
// The Facebook app secret
'app_secret' => '{app-secret}',
// The default fall-back access token if one is not provided
'default_access_token' => '{access-token}',
// A custom HTTP client handler that must implement
// Facebook\HttpClients\FacebookHttpClientInterface
'http_client_handler' => new MyCustomHttpClient(),
// Force use of the cURL HTTP client
'use_curl_http_client' => true,
// Force use of the stream wrapper HTTP client
'use_stream_http_client' => true,
// Force use of the Guzzle HTTP client (requires Guzzle)
'use_guzzle_http_client' => true,
// Enable the graph.beta.facebook.com endpoint
'enable_beta_mode' => true,
// Change the default Graph version
'default_graph_version' => 'v1.0',
]);
```

Finally this implementation will fallback to the `FACEBOOK_APP_ID` & `FACEBOOK_APP_SECRET` environment variables so you can new up with no config at all.

```php
$fb = new Facebook();
```

This is really handy when your server config is set in the environment variables for better security & easier deployment. :)

I'd like to add helper factories, etc to this but it's not 100% necessary for 4.1 launch.

Hope you guys like it!