Checking for event-rsvp status and showing disabled/enabled RSVP-button

后端 未结 3 657
日久生厌
日久生厌 2021-01-15 02:23

I\'m still a bit unsure how I would find this in the documentation, but I\'d like to check whether the logged-in user has RSVP\'ed to an fb-event or not, and show the \"I\'m

相关标签:
3条回答
  • 2021-01-15 02:57

    Actually, there's an easier way to do all of this. The problem with the FQL query is that there's a delay of like 15-30 seconds after you submit the RSVP for the status to show up. But this works in the graph API without pagination. Try a GET request in this form:

    /[event id]/invited?user=[user_id]&access_token=[access_token]

    It'll return a data structure with the rsvp_status if the user has RSVPed at all, including for public events where that user wasn't technically "invited." If the data structure is blank, then they haven't RSVPed at all.

    0 讨论(0)
  • 2021-01-15 03:12

    You can query the event_member FQL table, something like:

    FB.api(
        {
            method: 'fql.query',
            query: 'select rsvp_status from event_member where eid = "EVENT_ID" and uid=me()'
        }, function(response) {
            alert(response[0].rsvp_status);
        }
    );
    

    Would return (alert) something like: declined

    0 讨论(0)
  • 2021-01-15 03:15

    You can use the Graph API to do this. There are two scenarios that may be of interest: (1) For an event, you want to list if the user is attending, and (2) for a user, you want to list the event's they're attending. You need the user_events permission for both scenarios.

    For (1): HTTP GET /EVENT_ID/attending. This will return an array of objects with {id, name, rsvp_status} fields. Look for the User ID you're interested in and, if they've RSVP'd, then the rsvp_status field will tell you if they're attending.

    For (2): HTTP GET /USER_ID/events. This will return all the events for the user with several fields, but also {id, name, rsvp_status} fields as above. This time, look for the Event ID you're interested in, and then the rsvp_status field will tell you if the current user is attending, not attending, maybe attending, or hasn't RSVP'd (i.e. rsvp_status is unsure).

    0 讨论(0)
提交回复
热议问题