How to iterate through facebook response of a users events

Using Visual Studio for ios app with XAMARIN facebook component.
I have used the facebookiOSSample as a basis for Facebook login.
I get an NSDictionary object userInfo back from

        var fields = "?fields=id,name,email,events,about,hometown";
        var request = new GraphRequest("/" + userId + fields, null, AccessToken.CurrentAccessToken.TokenString, null, "GET");
        var requestConnection = new GraphRequestConnection();
        requestConnection.AddRequest(request, (connection, result, error) => {
            // Handle if something went wrong with the request
            if (error != null)
            {
                new UIAlertView("Error...", error.Description, null, "Ok", null).Show();
                return;
            }

            NSDictionary userInfo = (result as NSDictionary);

Then i can get a NSObject from userInfo["events"]

This contains th e correct events data, i suspect it to be a JSON, Facebook document described it as "event nodes" .

I want to iterate thru this events data info to extract th e name and id of events.

I have lost my thoughts, tried foreach approach but got stopped by enumeration error

I am practical amateur but do try hard to help myself, any assistance appreciated.

Tagged:

Answers

  • My got this view of th e data from userInfo["events"] from an addwatch in visual studio

    {{
    data = (
    {
    description = "A event for multicopters of all types.";
    "end_time" = "2015-09-20T16:00:00+0930";
    id = 802666679848532;
    name = "Multistock 2015";
    place = {
    id = 538326486185160;
    location = {
    city = "Two Wells";
    country = Australia;
    latitude = "-34.571832570594";
    longitude = "138.4746407135";
    state = SA;
    };
    name = "Concorde Model Flying Club";
    };
    "rsvp_status" = attending;
    "start_time" = "2015-09-20T09:00:00+0930";
    },
    {
    description = abc;
    id = 496165853886150;
    name = Test;
    place = {
    name = "3 rosedale ave wattle park";
    };
    "rsvp_status" = attending;
    "start_time" = "2015-08-28";
    },

  • but when i do it from Graph API exploerer it get below which looks a bit more JSON formated

    {
    "events": {
    "data": [
    {
    "description": "A event for multicopters of all types.",
    "end_time": "2015-09-20T16:00:00+0930",
    "name": "Multistock 2015",
    "place": {
    "name": "Concorde Model Flying Club",
    "location": {
    "city": "Two Wells",
    "country": "Australia",
    "latitude": -34.571832570594,
    "longitude": 138.4746407135,
    "state": "SA"
    },
    "id": "538326486185160"
    },
    "start_time": "2015-09-20T09:00:00+0930",
    "id": "802666679848532",
    "rsvp_status": "attending"
    },
    {
    "description": "abc",
    "name": "Test",
    "place": {
    "name": "3 rosedale ave wattle park"
    },
    "start_time": "2015-08-28",
    "id": "496165853886150",
    "rsvp_status": "attending"
    },

Sign In or Register to comment.