您需要将以下代码放在应用程序的第一个访问页面之上:
$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);
}
Run Code Online (Sandbox Code Playgroud)
输入您自己的API密钥和密钥.谢谢
| 归档时间: |
|
| 查看次数: |
1678 次 |
| 最近记录: |