Graph API - Get events by owner/creator

后端 未结 4 1597
面向向阳花
面向向阳花 2021-02-01 08:56

Is there a way with the Facebook Graph API to get a list of all events created by a single profile? Our client creates a bunch of events and we want to pull a list of them all.

4条回答
  •  无人及你
    2021-02-01 09:27

    I basically used the FQL that @jhchen provided. However, it took me about 6 hours to figure out how to use that FQL. So I figured, I would provide you a working script. It's not perfect so please update it if you find a bug.

    1. Download Facebooks PHP SDK
    2. Add YOUR_APP_ID
    3. Add YOUR_APP_SECRET
    4. Add PAGE_ID
    5. Make changes to the FQL statement as you see fit. FQL Documentation

    Other than that you should be good to go. Also, I set the default timezone to America/Los_Angeles. This will probably cause problems for some of you, if anyone has a better way to handle the timezones please let me know.

    PHP Code:

    = ' . mktime() . '
                ORDER BY start_time ASC
        ';
    
        $ret_obj = $facebook->api(array(
            'method' => 'fql.query',
            'query' => $fql,
        ));
    
        $html = '';                            
        foreach($ret_obj as $key)
        {
            $facebook_url = 'https://www.facebook.com/event.php?eid=' . $key['eid'];
    
            $start_time = date('M j, Y \a\t g:i A', $key['start_time']);
            $end_time = date('M j, Y \a\t g:i A', $key['end_time']);
    
            $html .= '
                

    '.$key['name'].'

    '.$start_time.'

    '.$end_time.'

    '; } echo $html; }

提交回复
热议问题