Facebook: force user to login / install application using FBML

I'm new to Facebook apps, so I'm sorry if I have something wrong.

How can I offer users to install my application when visiting the canvas page of my application?

+5
source share
1 answer

You need to put below the code of the first page of access to your application:

$facebook = new Facebook($api_key, $secret);
$facebook->require_frame();
$user = $facebook->require_login();

//catch the exception that gets thrown if the cookie has an invalid session_key in it
try
{
    if (!$facebook->api_client->users_isAppUser())
    {
        $facebook->redirect($facebook->get_add_url());
    }
}
catch (exception $ex)
{
    //this will clear cookies for your application and redirect them to a login prompt
    $facebook->set_user(null, null);
    $facebook->redirect($iframepath);
}

Put your own API key and private key. Thanks

+5
source

All Articles