/ Published in: PHP

default facebook connect script
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<?PHP require 'src/facebook.php'; // download from github facebook php sdk // Create our Application instance (replace this with your appId and secret). 'appId' => 'YOUR_APP_ID', 'secret' => 'YOU_SECRET_KEY', 'cookie' => true, )); // We may or may not have this data based on a $_GET or $_COOKIE based session. // // If we get a session here, it means we found a correctly signed session using // the Application Secret only Facebook and the Application know. We dont know // if it is still valid until we make an API call using the session. A session // can become invalid if it has already expired (should not be getting the // session back in this case) or if the user logged out of Facebook. $session = $facebook->getSession(); $fbinfo = null; // Session based API call. if ($session) { try { $fbid = $facebook->getUser(); $fbinfo = $facebook->api('/me'); //print_r($fbinfo); } catch (FacebookApiException $e) { } } ?>
Comments
