Friday, June 8, 2012

Getting all my events via Facebook iOS SDK


In my iOS app, I get an access token using the following code:




[self.facebook authorize:[NSArray arrayWithObjects:@"user_events",
@"friends_events", nil]];



I then request my events with the following code:




[self.facebook requestWithGraphPath:@"me/events" andDelegate:friendsVC];



But as a response, I only get events I have RSVP'd to. I would like to get all my events including those I have not RSVP'd to.



Any ideas?


Source: Tips4all

4 comments:

  1. The request


    /me/events


    only gives you the events a user is (maybe) planning to attend. The response doesn't include events which the user has been invited to (but not responded to), or declined.

    There are other requests that may be of help:

    You can check if a user has been invited to an event like so:


    /EVENT_ID/invited/USER_ID


    RSVP status can be checked by event:


    /EVENT_ID/attending

    /EVENT_ID/maybe

    /EVENT_ID/declined

    /EVENT_ID/invited


    where each request returns a list of users with the queried RSVP status.

    ReplyDelete
  2. You can get list of events regardless of their RSVP status with next FQL query:

    SELECT eid, name, venue, location, start_time FROM event WHERE eid IN (
    SELECT eid from event_member WHERE uid = me()
    )


    This will not return RSVP status for each event but just events details. You may wish to use Batch Requests to get both details of events and rsvp_status with same query.

    https://graph.facebook.com/?method=post&batch=[
    {
    "name":"rsvp",
    "relative_url":"fql?q=SELECT+eid,rsvp_status+FROM+event_member+WHERE+uid=me()",
    "omit_response_on_success":false
    },
    {
    "relative_url":"?ids={result=rsvp:$.data.*.eid}"
    }
    ]


    See event and event_member table documentation for details on other fields you may wish to retrieve.

    Notes:


    Starting July 5th, an access token will be required to access even public events.

    ReplyDelete
  3. I think you may get events by fql query. You need to try this.

    Also see this How-To: Use the Graph API to Manage Events.

    You will need to HTTP Get the following from the Graph API:

    fql?q=SELECT uid,eid,rsvp_status FROM event_member WHERE uid = me()

    You can get back all statuses from that call.

    {
    "data": [
    {
    "uid": "723020003",
    "eid": "19935786340002",
    "rsvp_status": "not_replied"
    },
    {
    "uid": "723020003",
    "eid": "234524000290351",
    "rsvp_status": "attending"
    },
    {
    "uid": "723020003",
    "eid": "210091000081240",
    "rsvp_status": "declined"
    },
    {
    "uid": "723020003",
    "eid": "210091000341240",
    "rsvp_status": "unsure"
    }
    ]
    }

    ReplyDelete
  4. This isn't a complete solution, and this may not work, but see if it's possible to get access to the iCal feed of a user's Facebook events. I subscribe to my iCal feed, and I noticed that all events, even new ones that I have yet to RSVP to are included in the feed.

    Something to try anyway!

    ReplyDelete