FQL查询向我显示随机facebook事件的男性和女性参与者的数量

时间:2014-02-28 15:12:46

标签: facebook facebook-graph-api facebook-fql fql.multiquery

好吧,我这里的代码是一个FQL查询,它向我展示了来自facebook的随机事件的所有与会者。

$fql = "SELECT uid FROM event_member WHERE eid = 461462343953933 AND start_time >= now() ORDER BY start_time descLIMIT 50 ";    

$param  =   array(
    'method'    => 'fql.query',
    'query'     => $fql,
    'callback'  => ''
);

$fqlResult   =   $facebook->api($param);


foreach( $fqlResult as $keys => $values ){
    $start_date = date( 'l, F d, Y', $values['start_time'] );
    $start_time = date( 'g:i a', $values['start_time'] );

    echo "<div style='float:left; display:inline;margin-left:4px;'>";
    echo "<a href='https://www.facebook.com/profile.php?id={$values['uid']}' target='_blank'><img src='https://graph.facebook.com/{$values['uid']}/picture'></a></div>";   

}

但是,我需要知道如何编写一个查询,显示男性与会者的数量以及随机事件中与会者的数量。

1 个答案:

答案 0 :(得分:0)

FQL查询无法返回聚合。您可以使用此查询

select uid, sex from user where uid in (SELECT uid FROM event_member WHERE eid = 461462343953933 AND start_time >= now() ORDER BY start_time desc) LIMIT 50

并在您的应用程序中自行计算生成的性别信息。