Apidcloud

Retrieve feed from facebook - sdk 4.0 php

Nov 23rd, 2014
281
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. session_start();
  3.  
  4. define('__ROOT__', dirname(dirname(dirname(__FILE__))));
  5. require (__ROOT__.'/resources/facebook-php-sdk-v4-4.0-dev/autoload.php');
  6.  
  7. // added in v4.0.5
  8. use Facebook\FacebookHttpable;
  9. use Facebook\FacebookCurl;
  10. use Facebook\FacebookCurlHttpClient;
  11.  
  12. // added in v4.0.0
  13. use Facebook\FacebookSession;
  14. use Facebook\FacebookRedirectLoginHelper;
  15. use Facebook\FacebookRequest;
  16. use Facebook\FacebookResponse;
  17. use Facebook\FacebookSDKException;
  18. use Facebook\FacebookRequestException;
  19. use Facebook\FacebookOtherException;
  20. use Facebook\FacebookAuthorizationException;
  21. use Facebook\GraphObject;
  22. use Facebook\GraphSessionInfo;
  23. use Facebook\GraphUser;
  24.  
  25. // init app with app id and secret
  26. FacebookSession::setDefaultApplication('APP-ID','APP-SECRET');
  27.  
  28. // get app access_token
  29. $session = FacebookSession::newAppSession();
  30.  
  31. // make request to Facebook                        
  32. $request = new FacebookRequest( $session, 'GET', '/PAGE-ID/feed' ); // /PAGE-ID only would retrieve the basic info, like username
  33. $response = $request->execute();
  34. // get response as array
  35.  
  36.  
  37. $content = $response->getGraphObject();
  38. print_r($content);
  39. // output html
  40. ?>
RAW Paste Data