sentinel
sentinel

Reputation: 421

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?

Upvotes: 14

Views: 4111

Answers (5)

dac2009
dac2009

Reputation: 3561

Use /me/events for getting the events the user has responded to, and /me/events/not_replied for the others.

For example (assuming you have created a session):

[FBRequestConnection startWithGraphPath:@"/me/events/not_replied" completionHandler:^(FBRequestConnection *connection, id result, NSError *error)
{
    FBGraphObject* data = (FBGraphObject*)result;
    NSMutableArray* array = [data objectForKey:@"data"];

    //parse data etc..
}];

See https://developers.facebook.com/docs/graph-api/reference/v2.0/user/events/ for more info.

Upvotes: 0

Juicy Scripter
Juicy Scripter

Reputation: 25918

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.

Upvotes: 2

joshaidan
joshaidan

Reputation: 3872

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!

Upvotes: 0

Gunnar Karlsson
Gunnar Karlsson

Reputation: 28470

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.

Upvotes: 6

Somnath Muluk
Somnath Muluk

Reputation: 57656

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"
    }
  ]
}

Upvotes: 0

Related Questions