facebook app get authentication inside a facebook page

70 views Asked by At

I have a facebook page I have built an application to be in the page tab the application works fine with the original url it get the login from the facebook and return to the url

how i can get the authintication from the user without changing the url "inside the iframe" ?

require_once("facebook.php");
$facebook = new Facebook(array(
        'appId' => 'App_id',
        'secret' => 'Secret'));
$current_user = $facebook->getUser();

$params = array('scope' =>'email,user_likes,user_friends');
if ($current_user) { 
    try {
            $expiration = time() + 172800; 
            $cookie_value = $current_user . '|' . $expiration;
            setcookie('fbid', $cookie_value, $expiration , "/");
            echo '<script type="text/javascript">
            window.location = "like.php";
            </script>';
    } catch (FacebookApiException $e) {
        $login_url = $facebook->getLoginUrl($params);
        echo '<script type="text/javascript">
        window.location = "' . $login_url . '";
        </script>';
        exit;
        error_log($e->getType());
        error_log($e->getMessage());
    }
} else {
    $login_url = $facebook->getLoginUrl($params);
    echo '<script type="text/javascript">
        window.location = "'.$login_url.'";
        </script>';
    exit;
}
1

There are 1 answers

0
Hossam Aldeen Ahmed On BEST ANSWER

create a facebook tab application not web application and use JS SDK