Facebook event API

I have searched for a while google to find a way to get a random facebook event page by id onto a website. So far i have been succesfull in getting the all the event's information as in the title description a pics but i have a problem getting the rsvp status. I tried a couple of things to do so but was unsuccesful and now the script that i wrote won't even work when it worked fine yesterday.

here is my code :

require_once("facebook-platform/src/facebook.php");
$config = array();
$config['appId'] = 'aaaaaaa';
$config['secret'] = 'bbbbbbbbbb';
$config['fileUpload'] = false; // optional

$facebook = new Facebook($config);
// See if there is a user from a cookie
$user = $facebook->getUser();

if ($user) {
  try {
    // Proceed knowing you have a logged in user who's authenticated.
    $user_profile = $facebook->api('/me');
  } catch (FacebookApiException $e) {
    echo '<pre>'.htmlspecialchars(print_r($e, true)).'</pre>';
  $user = null;
  }
}
var_dump($user);// to check the returned user account which is int(0) and yesterday it
//worked fine giving me all the details

//now this is the code for getting the event
$fql='{
"event_info": "SELECT name,description, pic_small,pic_big, eid,venue,location  FROM       event WHERE eid =266159320165868", 
"event_venue":"SELECT name, username, page_id,location FROM page WHERE name IN (SELECT     venue.id FROM #event_info)"
}';

$setup  =   array(
'method'    => 'fql.multiquery',
'queries'     => $fql,
'callback'  => ''
);
$result   =   $facebook->api($setup);

//this code worked fine but now it doesen't anymore since i can't log in as a user

Another thing i would like tot do is get the attend button from an event does anyone have any ideas?

Upvotes: 0

Views: 1130

Answers (1)

cpilko
cpilko

Reputation: 11852

It looks like you've got three problems:

  1. is your code isn't working anymore. Log out of Facebook, restart your browser and clear the cache then log back into Facebook and and see if it works again.

  2. is you are looking for the rsvp status of a specific user to an event. To get this, you need to add a query to your multiquery above.

    'attending_event':'SELECT rsvp_status FROM event_member WHERE uid = me() AND eid = (SELECT eid FROM #event_info)'

  3. You can't get an "Attend" button for the event. You need to code your own button that POSTS to https://graph.facebook.com/EVENT_ID/attending when it is clicked by an authenticated user.

See the facebook documentation here for more information: https://developers.facebook.com/docs/reference/api/event/#attending

Upvotes: 1

Related Questions