Guest User

Untitled

a guest
Jan 20th, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.23 KB | None | 0 0
  1. if(!empty($event_id)) // if the event id is provided
  2. {//see if the user is logged in(now here is the big problem,
  3. if a user loggs in with the plugin it has no efect over this code
  4. so this if is always false when user visits for the first time)
  5. if($facebook->getUser())
  6. {
  7. $uid = $facebook->getUser();
  8.  
  9. if(!empty($_REQUEST['action'])){
  10.  
  11. $success = $facebook->api('/'.$event_id.'/attending', 'POST');
  12. if(!$success)
  13. {echo "Oops something went wrong try again!";}
  14. //else echo "<p>You are attending this event!</p>";
  15. }
  16. $fql ="{ 'attending_event':'SELECT rsvp_status FROM event_member WHERE uid =".$uid." AND eid = ".$event_id."'}";
  17. $a_setup = array(
  18. 'method' => 'fql.multiquery',
  19. 'queries' => $fql,
  20. 'callback' => ''
  21. );
  22. $a_result = $facebook->api($a_setup);
  23. if($a_result[0]['fql_result_set'][0]['rsvp_status'] == 'attending' )
  24. {
  25. echo "<a href='#' class='zocial facebook'>You're attending this event!</a>";
  26.  
  27. }
  28. else
  29. echo '</br><form name"location" action="" method="POST">
  30. <input type="submit" class="zocial facebook" value="Attend" /><input type="hidden" name="action" value="Attend" />
  31. </form>';
  32.  
  33. }
  34. else
  35. {
  36. $params = array(
  37. 'scope' => 'rsvp_event',
  38.  
  39. );
  40. $loginUrl = $facebook->getLoginUrl($params);
  41.  
  42. echo "<div class='zocial facebook'>You must <a href=".$loginUrl.">log in with facebook</a> to attend</div>";
  43. }
  44. }
  45. // /attend button
Add Comment
Please, Sign In to add comment