This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Feb 26th, 2012  |  syntax: None  |  size: 1.60 KB  |  views: 16  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <?php
  2.     //facebook application
  3.     //set facebook application id, secret key and api key here
  4.     $fbconfig['appid' ] = "";
  5.     $fbconfig['api'   ] = "";
  6.     $fbconfig['secret'] = "";
  7.  
  8.     //set application urls here
  9.     $fbconfig['baseUrl']    =   ""; //http://thinkdiff.net/demo/newfbconnect1/iframe;
  10.     $fbconfig['appBaseUrl'] =   ""; //http://apps.facebook.com/thinkdiffdemo;
  11.  
  12.     $uid            =   null; //facebook user id
  13.  
  14.     try{
  15.         include_once "facebook.php";
  16.     }
  17.     catch(Exception $o){
  18.         echo '<pre>';
  19.         print_r($o);
  20.         echo '</pre>';
  21.     }
  22.     // Create our Application instance.
  23.     $facebook = new Facebook(array(
  24.       'appId'  => $fbconfig['appid'],
  25.       'secret' => $fbconfig['secret'],
  26.       'cookie' => true,
  27.     ));
  28.  
  29.     //Facebook Authentication part
  30.     $session = $facebook->getSession();
  31.     $loginUrl = $facebook->getLoginUrl(
  32.             array(
  33.             'canvas'    => 1,
  34.             'fbconnect' => 0,
  35.             'req_perms' => 'email,publish_stream,status_update,user_birthday,user_location,user_work_history'
  36.             )
  37.     );
  38.  
  39.     $fbme = null;
  40.  
  41.     if (!$session) {
  42.         echo "<script type='text/javascript'>top.location.href = '$loginUrl';</script>";
  43.         exit;
  44.     }
  45.     else {
  46.         try {
  47.             $uid      =   $facebook->getUser();
  48.             $fbme     =   $facebook->api('/me');
  49.  
  50.         } catch (FacebookApiException $e) {
  51.             echo "<script type='text/javascript'>top.location.href = '$loginUrl';</script>";
  52.             exit;
  53.         }
  54.     }
  55.  
  56.     function d($d){
  57.         echo '<pre>';
  58.         print_r($d);
  59.         echo '</pre>';
  60.     }
  61. ?>
clone this paste RAW Paste Data