Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if(!empty($event_id)) // if the event id is provided
- {//see if the user is logged in(now here is the big problem,
- if a user loggs in with the plugin it has no efect over this code
- so this if is always false when user visits for the first time)
- if($facebook->getUser())
- {
- $uid = $facebook->getUser();
- if(!empty($_REQUEST['action'])){
- $success = $facebook->api('/'.$event_id.'/attending', 'POST');
- if(!$success)
- {echo "Oops something went wrong try again!";}
- //else echo "<p>You are attending this event!</p>";
- }
- $fql ="{ 'attending_event':'SELECT rsvp_status FROM event_member WHERE uid =".$uid." AND eid = ".$event_id."'}";
- $a_setup = array(
- 'method' => 'fql.multiquery',
- 'queries' => $fql,
- 'callback' => ''
- );
- $a_result = $facebook->api($a_setup);
- if($a_result[0]['fql_result_set'][0]['rsvp_status'] == 'attending' )
- {
- echo "<a href='#' class='zocial facebook'>You're attending this event!</a>";
- }
- else
- echo '</br><form name"location" action="" method="POST">
- <input type="submit" class="zocial facebook" value="Attend" /><input type="hidden" name="action" value="Attend" />
- </form>';
- }
- else
- {
- $params = array(
- 'scope' => 'rsvp_event',
- );
- $loginUrl = $facebook->getLoginUrl($params);
- echo "<div class='zocial facebook'>You must <a href=".$loginUrl.">log in with facebook</a> to attend</div>";
- }
- }
- // /attend button
Add Comment
Please, Sign In to add comment