Upgrade to Pro — share decks privately, control downloads, hide ads and more …

All about the new, NEW Facebook PHP SDK v4.1

All about the new, NEW Facebook PHP SDK v4.1

A 10 minute lightning talk presented at Nomad PHP on March 19th, 2015.

When developing on Facebook, things change all the time. And things are about to change once again with the release of the Facebook PHP SDK v4.1. It's got tons of new powerful features that have never existed in a Facebook PHP SDK before. This lightning talk is focused on giving a crash-course on the new Facebook PHP SDK v4.1 and it's features. By the end you should have the confidence to start using the new SDK within your own app.

Sammy Kaye Powers

March 19, 2015
Tweet

More Decks by Sammy Kaye Powers

Other Decks in Education

Transcript

  1. All About the By @SammyK For @nomadphp On March 19th,

    2015 new, NEW Facebook PHP SDK 4.1
  2. OAuth 2.0 Client $authUrl = $provider->getAuthorizationUrl();! $_SESSION['oauth2state'] = $provider->state;! header('Location:

    '.$authUrl);! ! // . . .! ! $token = $provider->getAccessToken(! ! 'authorization_code', [! 'code' => $_GET['code']! ]);! $user = $provider->getUserDetails($token);! printf('Hello %s!', $userDetails->firstName);
  3. Socialite Laravel 5 public function redirectToProvider() {! return Socialize::with(‘facebook')! !

    ! ! ->redirect();! }! ! public function handleProviderCallback() {! $user = Socialize::with(‘facebook')! ! ! ! ->user();! // $user->token;! }
  4. • Signed request support • Easy-as-pie file uploads • Easy

    batch request support • Easy-peasy pagination • Graph Nodes as collections Facebook PHP SDK
  5. Facebook\Facebook() • Handles fall-back config • Factory for helpers &

    entities • Helps with HTTP requests • Container to inject custom deps
  6. login from redirect $helper = $fb->getRedirectLoginHelper();! $login_link = $helper->! getLoginUrl(‘https://foo.com/fb');!

    ! echo '<a href="' . $login_link . '">'.! 'Log in!</a>'; Route: / Authentication
  7. $data = [! ! ! ‘message’ => ‘Hi from Nomad

    PHP!’,! ];! ! $res = $fb->post(‘/me/feed’, $data); $fb = Facebook\Facebook() Request & Response POST
  8. Injectable Persistent Data Storage: `PersistentDataInterface` Injectable HTTP Client: `FacebookHttpClientInterface` Injectable

    CSPRNG: `PseudoRandomStringGeneratorInterface` Injectable URL detection: `UrlDetectionInterface` Advanced Integration
  9. $data = [
 'message' => 'My awesome photo.',
 'source' =>

    $fb->fileToUpload('/my/photo.jpg'),
 ];! ! $res = $fb->post(‘/me/feed’, $data); $fb = Facebook\Facebook() File Uploads Photo example
  10. $data = [! 'title' => 'My video’,
 'description' => 'My

    awesome video.',
 'source' => $fb->videoToUpload('/my/photo.mp4'),
 ];! ! $res = $fb->post(‘/me/feed’, $data); $fb = Facebook\Facebook() File Uploads Video example