getting status messages from facebook using Graph API

Discussion in 'iOS Programming' started by kingthong, Jan 19, 2011.

  1. kingthong, Jan 19, 2011
    Last edited: Jan 19, 2011

    macrumors member

    Sep 20, 2010
    Somewhere but not here.
    I'm using the Graph API to to integrate an app with Facebook.

    So basically i want an app that will display all the status messages i've posted with the no. of comments and no. of likes. and possibly show who has liked and commented the corresponding status.
    Now while testing the app i hardcoded my own FB profile using,<my_username>/statuses?access_token=....

    It worked and this returned some JSON string with which i could retrieve the data i wanted.

    Now when writing the app i had to extend the functionality for anyone to get these stats about their status messages. Hence they used to first login using standard FB login mechanism and then i used the URL:

    But for some reason it didn't work. i looked at the documentation at again and realized that when the 'me' page is used there is no option to access only 'statuses'.

    Instead i've to access the 'feed' page using and then segregate the statuses.

    have a few questions regarding this:
    a. Is there a better way to do it?
    b. and on my feed, even if somebody else posts, say a Birthday msg, the type = status. Hence while parsing JSON, how do i pick the status msgs only i've written?

    Thanks for the help!
  2. thread starter macrumors member

    Sep 20, 2010
    Somewhere but not here.
    Ok, i've found a soultion. I'm not sure if it's the optimal one.

    What you can do is use

    make a NSURLRequest to
    (this is after the user has logged on using username and pwd)

    This will return a JSON object like so:

    "id": "123456",
    "name": "XYZ",
    "first_name": "X
    "last_name": "YZ",
    "link": "",
    "locale": "en_GB",
    "verified": true,

    Then use NSString userId = [numbers valueForKey: @"id"] to get the ID.

    You can then query for statuses using

    where id = userId.

    Hope this is clear.
  3. thread starter macrumors member

    Sep 20, 2010
    Somewhere but not here.
    okay i seem to have run into a roadblock..

    I implemented what i have described above. The only problem is it works for one profile and not for the others.
    the first time i tried out the program, i did so with my usual facebook account. the program works fine and i get to view all my status updates.

    Now when i try the same program with any other profile it doesn't work. All i get is a string that says "{"data":[]}"

    Does it have anything to do with the access_token? I'd really like some help.
    Let me know if i've to post the code here.


    ps: just to clarify - when i say other profiles, it means i've got friends to log in and try the app out and it doesn't work.

Share This Page