LoginSignup
2
2

More than 5 years have passed since last update.

直近5件のFacebookイベントをFQLで取って来る

Last updated at Posted at 2012-04-26

Graph APIだと取れないものがあったりするので、FQLを使うサンプル。

2012/4/24現在、API仕様の変更でこのままだと上手くいかず。調査中。

<?php
function get_events ($fid, $appid, $secret, $limit = 5) {
    $fb = new Facebook(array('appId'=>$appid, 'secret'=>$secret));
    $yesterday = time()-60*60*24;//24時間前のタイムスタンプ
    $fql = <<<____FQL
        SELECT creator, description, eid, end_time, location, name, pic, pic_big, pic_small, start_time
        FROM event
        WHERE
            eid in (
                SELECT eid 
                FROM event_member 
                WHERE uid = $fid AND $yesterday < start_time)
            AND privacy = 'OPEN'
        ORDER BY start_time ASC
        LIMIT $limit
____FQL;
    return $fb->api(array('method'=>'fql.query','query'=>$fql));
}

実動例はこちら。

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2