Posted By

cdog on 03/08/11


Tagged

php connect facebook


Versions (?)

Facebook Connect Script


 / Published in: PHP
 

default facebook connect script

  1. <?PHP
  2.  
  3. require 'src/facebook.php'; // download from github facebook php sdk
  4.  
  5. // Create our Application instance (replace this with your appId and secret).
  6. $facebook = new Facebook(array(
  7. 'appId' => 'YOUR_APP_ID',
  8. 'secret' => 'YOU_SECRET_KEY',
  9. 'cookie' => true,
  10. ));
  11.  
  12. // We may or may not have this data based on a $_GET or $_COOKIE based session.
  13. //
  14. // If we get a session here, it means we found a correctly signed session using
  15. // the Application Secret only Facebook and the Application know. We dont know
  16. // if it is still valid until we make an API call using the session. A session
  17. // can become invalid if it has already expired (should not be getting the
  18. // session back in this case) or if the user logged out of Facebook.
  19. $session = $facebook->getSession();
  20.  
  21. $fbinfo = null;
  22. // Session based API call.
  23. if ($session) {
  24. try {
  25. $fbid = $facebook->getUser();
  26. $fbinfo = $facebook->api('/me');
  27. //print_r($fbinfo);
  28. } catch (FacebookApiException $e) {
  29. error_log($e);
  30. }
  31. }
  32.  
  33. ?>

Report this snippet  

You need to login to post a comment.