1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

PHP Facebook Connect Help

Discussion in 'Facebook API' started by crazyryan, May 22, 2010.

  1. #1

    Does anyone know why $facebook->getSession() returns true, $facebook->getUser() returns my uid, but $fbme = $facebook->api('/me'); returns false, so does all the other API calls.

    All help appreciated.

    require 'facebook.php';
    // Create our Application instance.
    $facebook = new Facebook(array(
      'appId'  => 'id',
      '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();
    $me = null;
    // Session based API call.
    if ($session) {
          $uid = $facebook->getUser();
          $fbme = $facebook->api('/me');
                $param  =   array(
                    'method'  => 'users.getinfo',
                    'uids'    => $uid,
                    'fields'  => 'name,current_location,profile_url',
                    'callback'=> ''
                echo $uid;
                $userInfo   =   $facebook->api($param);
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml">
    <div id="fb-root"></div>
    <script src="http://connect.facebook.net/en_US/all.js"></script>
      FB.init({appId: 'id', status: true, cookie: true, xfbml: true});
      FB.Event.subscribe('auth.sessionChange', function(response) {
        if (response.session) {
          alert('logged in');
        } else {
          alert('logged out');
    <fb:login-button autologoutlink="true" size="medium" background="white" length="short" perms="email,user_birthday,status_update,publish_stream"></fb:login-button>

    crazyryan, May 22, 2010 IP
  2. roopajyothi

    roopajyothi Active Member

    Likes Received:
    Best Answers:
    Trophy Points: