我是Facebook应用程序的新手,如果我出错了,请原谅我。
如何在用户访问应用程序的画布页面时提示用户安装我的应用程序?
答案 0 :(得分:5)
您需要将以下代码放在应用程序的第一个访问页面之上:
$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);
}
输入您自己的API密钥和密钥。感谢