简体   繁体   中英

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? 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.

Any Ideas?

Check the existence of the facebook API cookie. in the facebook api you have the facebook.php file which manages the session and cookies. This file shall be included at the beginning of every php page that uses the FB authentication.

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.

if( $fb_me )
{
  echo "you are authenticated via FB API as user id:".$fb_uid;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM