daily pastebin goal
23%
SHARE
TWEET

Untitled

a guest Jul 22nd, 2014 319 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?
  2. session_start();
  3.  
  4. // FACEBOOK API
  5.  
  6. // include required files form Facebook SDK
  7. require_once( 'includes/Facebook/HttpClients/FacebookHttpable.php' );
  8. require_once( 'includes/Facebook/HttpClients/FacebookCurl.php' );
  9. require_once( 'includes/Facebook/HttpClients/FacebookCurlHttpClient.php' );
  10.  
  11. require_once( 'includes/Facebook/Entities/AccessToken.php' );
  12. require_once( 'includes/Facebook/Entities/SignedRequest.php' );
  13.  
  14. require_once( 'includes/Facebook/FacebookSession.php' );
  15. require_once( 'includes/Facebook/FacebookRedirectLoginHelper.php' );
  16. require_once( 'includes/Facebook/FacebookSignedRequestFromInputHelper.php' ); // added in v4.0.9
  17. require_once( 'includes/Facebook/FacebookRequest.php' );
  18. require_once( 'includes/Facebook/FacebookResponse.php' );
  19. require_once( 'includes/Facebook/FacebookSDKException.php' );
  20. require_once( 'includes/Facebook/FacebookRequestException.php' );
  21. require_once( 'includes/Facebook/FacebookOtherException.php' );
  22. require_once( 'includes/Facebook/FacebookAuthorizationException.php' );
  23.  
  24. // these two classes required for canvas and tab apps
  25. require_once( 'includes/Facebook/FacebookCanvasLoginHelper.php' );
  26. require_once( 'includes/Facebook/FacebookPageTabHelper.php' );
  27.  
  28. require_once( 'includes/Facebook/GraphObject.php' );
  29. require_once( 'includes/Facebook/GraphSessionInfo.php' );
  30.  
  31. use Facebook\HttpClients\FacebookHttpable;
  32. use Facebook\HttpClients\FacebookCurl;
  33. use Facebook\HttpClients\FacebookCurlHttpClient;
  34.  
  35. use Facebook\Entities\AccessToken;
  36. use Facebook\Entities\SignedRequest;
  37.  
  38. use Facebook\FacebookSession;
  39. use Facebook\FacebookRedirectLoginHelper;
  40. use Facebook\FacebookSignedRequestFromInputHelper; // added in v4.0.9
  41. use Facebook\FacebookRequest;
  42. use Facebook\FacebookResponse;
  43. use Facebook\FacebookSDKException;
  44. use Facebook\FacebookRequestException;
  45. use Facebook\FacebookOtherException;
  46. use Facebook\FacebookAuthorizationException;
  47. use Facebook\GraphObject;
  48. use Facebook\GraphSessionInfo;
  49.  
  50. // these two classes required for canvas and tab apps
  51. use Facebook\FacebookCanvasLoginHelper;
  52. use Facebook\FacebookPageTabHelper;
  53.  
  54. $appid = '00000000000000';
  55. $secret = '00000000000000000000000';
  56.  
  57. // init app with app id and secret
  58. FacebookSession::setDefaultApplication($appid,$secret);
  59.  
  60. // init page tab helper
  61. $pageHelper = new FacebookPageTabHelper();
  62.  
  63. // get session from the page
  64. $pageSession                            = $pageHelper->getSession();
  65.  
  66. $_SESSION['token']                      = $pageSession->getToken();
  67. $_SESSION['p_uid']                      = $pageHelper->getUserId();
  68. $_SESSION['p_pid']                      = $pageHelper->getPageId();
  69. $_SESSION['p_like']                     = $pageHelper->isLiked();
  70. $_SESSION['p_admin']            = $pageHelper->isAdmin();
  71.  
  72. $session = new FacebookSession($_SESSION['token']);
  73. echo "Token: ".$_SESSION['token']."<br>";
  74.  
  75. echo "<pre>";
  76. print_r($session);
  77. echo "</pre>";
  78.  
  79. try{
  80.         $session->validate($appid ,$secret);
  81. }catch( FacebookAuthorizationException $ex){
  82.         // Session is not valid any more, get a new one.
  83.         echo $ex;
  84.         $session ='';
  85. }
  86. ?>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top