0
votes

I'm trying to retrieve all facebook events that a page that I have created, has been invited to. I created an App and following is the code I got from http://www.codeofaninja.com/2011/07/display-facebook-events-to-your-website.html:


    //requiring FB PHP SDK
    require 'fb-sdk/src/facebook.php';

    //initializing keys
    $facebook = new Facebook(array(
        'appId'  => '[app_id>],
        'secret' => '[app_secret]',
        'cookie' => true, // enable optional cookie support
    ));

    $fql    =   "SELECT name, pic, start_time, end_time, location, description 
                FROM event WHERE eid IN ( SELECT eid FROM event_member WHERE uid = 100001660923071 ) 
                ORDER BY start_time asc";
    $param  =   array(
    'method'    => 'fql.query',
    'query'     => $fql,
    'callback'  => ''
    );

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

    print_r($fqlResult);

Now the problem is that it works fine when the uid in the query is set to '221167777906963'(its the UID from the example code and it works wine with any app-id/secret combination) but when I set it to the uid of the page I am the owner of none of the events get returned. Is there something I'm missing? I double checked on my pages>accounts settings>apps to see if the app that I created had permission to the page and it does. Its a public page. What am I missing in the flow to give this app permission to get access to my pages events? The same query works fine if i run it in the Graph API Explorer with an access token that I generate for user_events.

I'm basically trying to understand why a particular Wordpress Plugin called FB Sync Events isn't working and the app authentication is what seems to be failing cuz the $facebook->api is returning nothing for a fql.query JUST for my page. QQ

2

2 Answers

0
votes

For accessing the page's events, you might need to use a PAGE access token. Page access tokens are easy to get. For the page administrator's user access token, call Graph /me/accounts and in there will by the page along with an access token for that page. That is what is called a "Page Access Token". Then using that Page access token, call your FQL statement.

0
votes

As far as I know it's no possible to display the events you have been invited to if you create a Facebook page instead of a profile. Since when you create a page you only have users who like you page. This means they can interact with the content you publish but they can't interact with you as a brand or company.

On the other hand when you create a profile you have users who are your friends and they can interact with you and the content you publish in many ways, including being able to be invited to events.