View Full Version : getting status messages from facebook using Graph API

Jan 19, 2011, 05:50 AM
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,


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 http://developers.facebook.com/docs/api 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 https://graph.facebook.com/me/feed?access_token=..... 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!

Jan 20, 2011, 03:47 AM
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 https://graph.facebook.com/me?access_token=....
(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": "http://www.facebook.com/X.YZ",
"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.

Jan 21, 2011, 04:02 AM
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.