Facebook Fql 状态表查询 - php 不工作

发布于 2024-10-13 07:40:45 字数 1363 浏览 2 评论 0原文

我有这个漂亮的通用代码。如果我登录(应用程序管理员),它会显示我的所有状态。如果我使用任何其他用户登录,则不会显示任何内容。为什么?

  <?php 
 header('p3p: CP="NOI ADM DEV PSAi COM NAV OUR OTR STP IND DEM"');

include_once('facebook.php');


     $app_id = '289544004746';


// Create our Application instance (replace this with your appId and secret).
$facebook = new Facebook(array(
  'appId' => '289544004746',
  'secret' => '5772f9f5abbcc84e794c28169a399d4e',
  'cookie' => true,
));


$session = $facebook->getSession();

$me = null;
// Session based API call.
if ($session) {
  try {
    $uid = $facebook->getUser();
    $me = $facebook->api('/me');
  } catch (FacebookApiException $e) {
    error_log($e);
  }
}

// login or logout url will be needed depending on current user state.
if ($me) {
  $logoutUrl = $facebook->getLogoutUrl(array('next' => 'http://autobotcentral.info/logout.php'));
echo "<a href='$logoutUrl'>Log out </a>";
} else {
  $loginUrl = $facebook->getLoginUrl(array('req_perms' => 'user_activities,user_status,read_status'));
echo "<a href='$loginUrl'>Login</a>";
?>
<html>
<head>

</head>
</html> 
<?php
}


$result = $facebook->api(array(
    'query' => 'SELECT uid,status_id,message FROM status WHERE uid = me()', 
    'method' => 'fql.query'));
print_r($result);
?>

I have this pretty stock generic code. If i'm logged in (app admin) it shows all my status. If I log in with any other user, it shows nothing. Why?

  <?php 
 header('p3p: CP="NOI ADM DEV PSAi COM NAV OUR OTR STP IND DEM"');

include_once('facebook.php');


     $app_id = '289544004746';


// Create our Application instance (replace this with your appId and secret).
$facebook = new Facebook(array(
  'appId' => '289544004746',
  'secret' => '5772f9f5abbcc84e794c28169a399d4e',
  'cookie' => true,
));


$session = $facebook->getSession();

$me = null;
// Session based API call.
if ($session) {
  try {
    $uid = $facebook->getUser();
    $me = $facebook->api('/me');
  } catch (FacebookApiException $e) {
    error_log($e);
  }
}

// login or logout url will be needed depending on current user state.
if ($me) {
  $logoutUrl = $facebook->getLogoutUrl(array('next' => 'http://autobotcentral.info/logout.php'));
echo "<a href='$logoutUrl'>Log out </a>";
} else {
  $loginUrl = $facebook->getLoginUrl(array('req_perms' => 'user_activities,user_status,read_status'));
echo "<a href='$loginUrl'>Login</a>";
?>
<html>
<head>

</head>
</html> 
<?php
}


$result = $facebook->api(array(
    'query' => 'SELECT uid,status_id,message FROM status WHERE uid = me()', 
    'method' => 'fql.query'));
print_r($result);
?>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

朮生 2024-10-20 07:40:45

您需要获得user_status扩展权限才能检索用户的状态

http://developers .facebook.com/docs/authentication/permissions

您可以使用 FB.登录

You need to receive user_status extended permision to retrieve user's status

http://developers.facebook.com/docs/authentication/permissions

You can do that using FB.login

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文