简体   繁体   English

PHP Facebook API。 如何通过API判断我的应用程序是否处于活动状态?

[英]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.

相关问题 我向Twitter API提出了请求。 如何从PHP脚本获得对JavaScript的JSON响应? - I made a request to the Twitter API. How can I get the JSON response from my PHP script to my JavaScript? 使用Facebook Graph API,我可以访问相册的JSOD,但不能通过PHP SDK通过api调用 - Using Facebook Graph API I can access the JSOD for my album but not through an api call via PHP SDK 如何判断我在php中使用哪个facebook版API - How to tell which facebook version API i'm using in php 通过“我的应用程序名称”在Facebook上发布API - Facebook api post via “my application name” Facebook API。 通过社交插件评论通知 - Facebook API. Notification via social plugin comments Facebook API。 无法使用来自PHP的有效访问令牌在页面上发布 - Facebook API. Can't publish on page with valid access token from PHP 如何通过 Facebook API 发布多张照片 - How do I can post a multiple photos via Facebook API 我正在向我的 API 发布一组对象。 如何访问这些对象的属性? - I am POST-ing an array of objects to my API. How can I access the properties of those objects? Facebook 图 API。 如何从帖子中获得评论 - Facebook Graph API. How to get comment from post 如何为我的PHP Facebook应用程序创建离线环境? - How can I create an offline environment for my PHP Facebook application?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM