How to avoid my this facebook app api login page?

Posted by user1035140 on Stack Overflow See other posts from Stack Overflow or by user1035140
Published on 2011-11-18T09:45:49Z Indexed on 2011/11/18 9:50 UTC
Read the original article Hit count: 183

Filed under:

I got a problem regrading with my apps which is once I go to my apps, it sure will show me a login page instead of allow page?

it always display the login page 1st then only display allow page, I had tried other apps, if I am 1st time user, It sure will appear the allow page only, it did not show me the login page.

my question is how to I avoid my login page direct go to allow page?

here is my login page picture enter image description here

here is my apps link

https://apps.facebook.com/christmas_testing/

here is my facebook php jdk api coding

<?php
$fbconfig['appid' ] = "XXXXXXXXXXXXX";
$fbconfig['secret'] = "XXXXXXXXXXXXX";
$fbconfig['baseUrl']    =   "myserverlink";
$fbconfig['appBaseUrl'] =   "http://apps.facebook.com/christmas_testing/";

if (isset($_GET['code'])){
    header("Location: " . $fbconfig['appBaseUrl']);
    exit;
}
if (isset($_GET['request_ids'])){
    //user comes from invitation
    //track them if you need
     header("Location: " . $fbconfig['appBaseUrl']);
}

$user   =   null; //facebook user uid
try{
    include_once "facebook.php";
}
catch(Exception $o){
    echo '<pre>';
    print_r($o);
    echo '</pre>';
}
// Create our Application instance.
$facebook = new Facebook(array(
  'appId'  => $fbconfig['appid'],
  'secret' => $fbconfig['secret'],
  'cookie' => true,
));

//Facebook Authentication part
$user = $facebook->getUser();

$loginUrl   = $facebook->getLoginUrl(
        array(
            'scope' => 'email,publish_stream,user_birthday,user_location,user_work_history,user_about_me,user_hometown'
        )
);
if ($user) {
  try {
    // Proceed knowing you have a logged in user who's authenticated.
    $user_profile = $facebook->api('/me');
  } catch (FacebookApiException $e) {
    //you should use error_log($e); instead of printing the info on browser
    d($e);  // d is a debug function defined at the end of this file
    $user = null;
  }
}

if (!$user) {
    echo "<script type='text/javascript'>top.location.href = '$loginUrl';</script>";
    exit;
}

//get user basic description
$userInfo = $facebook->api("/$user");

function d($d){
    echo '<pre>';
    print_r($d);
    echo '</pre>';
}

?>

© Stack Overflow or respective owner

Related posts about facebook-php-sdk