开发者

How do I use Facebook php-sdk correctly

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜