[英]PHP Facebook API. How can I tell if my application is active via the API?
Does anyone know whether there is an API call which will tell me whether an application is still active? 有谁知道是否有API调用会告诉我应用程序是否仍处于活动状态? For example, I have a login system where users can sign in with their facebook credentials, so I wiould like to periodically check that the application that the login uses, is still active facebbok side.
例如,我有一个登录系统,用户可以在其中使用其Facebook凭据登录,因此我想定期检查该登录所使用的应用程序是否仍处于激活状态。
Any Ideas? 有任何想法吗?
Check the existence of the facebook API cookie. 检查是否存在facebook API cookie。 in the facebook api you have the facebook.php file which manages the session and cookies.
在facebook api中,您具有用于管理会话和cookie的facebook.php文件。 This file shall be included at the beginning of every php page that uses the FB authentication.
该文件应包含在使用FB身份验证的每个php页面的开头。
Locate this part : 找到这部分:
$session = $facebook->getSession();
$fb_me = null;
// Session based graph API call
if ($session) {
try {
$fb_me = $facebook->api('/me');
$fb_uid = $facebook->getUser();
} catch (FacebookApiException $e) {
d($e);
}
}
Later in your code, check whether fb_me exists, if yes then you are authenticated via FB and you can use the other variables of the API to get information about the user. 在代码的稍后部分,检查fb_me是否存在,如果存在,则通过FB进行身份验证,然后可以使用API的其他变量来获取有关用户的信息。
if( $fb_me )
{
echo "you are authenticated via FB API as user id:".$fb_uid;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.