开发者

How do I use Facebook php-sdk correctly

开发者 https://www.devze.com 2023-02-18 09:07 出处:网络
Currently I use Facebook php-sdk. Example code from the tutorial. $session = $facebook->getSession();

Currently I use Facebook php-sdk.

Example code from the tutorial.

$session = $facebook->getSession();
$me      = null;

if ($session) {
  try {
    $uid = $facebook->getUser();
    $me = $facebook->api('/me');
  } catch (FacebookApiException $e) {
    error_log($e);
  }
}

Now on my edit or submit content I write something like this

if(isset($me)) {
  // can edit
} else {
  // logout
}

This is working fine, but sometimes the $me will return to empty a开发者_开发百科rray and user will logout. How to use $me correctly.

Let me know..


From my test here will working fine

if(isset($me) && $facebook->api('/me')) {
  // can edit
} else {
  // logout
}
0

精彩评论

暂无评论...
验证码 换一张
取 消