为什么我不能从event_member表中检索数据? Facebook的

时间:2013-03-09 23:27:12

标签: php facebook facebook-fql

由于某种原因,我的代码不起作用,我不知道为什么。这种格式适用于其他表,但是当我尝试从event_member表中检索事件id时,它没有返回任何内容。有什么我做错了。我知道我参加了几个活动,所以它必须归还它们。

require_once 'facebook.php';    //Facebook class

$Facebook = new Facebook($config);                  //Initialize Facebook
$fb = $Facebook->getUser();                             //Get the user

//Authorize the user
if ($fb)
{
    try 
    {
        $user = $Facebook->api('/me');
    } 
    catch (FacebookApiException $e) 
    {
        echo "There was an unexpected error. Please contact us.";
        $fb = null;
    }
}

try
{
    $fql = "SELECT eid FROM event_member WHERE uid = me()";
    $param = array('method' => 'fql.query', 'query' => $fql, 'callback' => '');

    $result = $Facebook->api($param);

    foreach ($result as $row)
    {
        echo $row["eid"] . "<br/>";
    }
}
catch (FacebookApiException $e) 
{
  echo $e;
}

1 个答案:

答案 0 :(得分:0)

  

要阅读您需要的event_member表:非公开活动的 user_events 权限或查看用户参加的所有活动

来源: https://developers.facebook.com/docs/reference/fql/event_member/


How to ask for permissions in PHP:

$params = array(
  'scope' => 'read_stream, friends_likes',
  'redirect_uri' => 'https://www.myapp.com/post_login_page'
);

$loginUrl = $facebook->getLoginUrl($params);