Go Back   MacRumors Forums > Apple Systems and Services > Programming > iPhone/iPad Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Jan 19, 2011, 06:50 AM   #1
kingthong
macrumors member
 
Join Date: Sep 2010
Location: Somewhere but not here.
getting status messages from facebook using Graph API

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,

https://graph.facebook.com/<my_usern...ess_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:

https://graph.facebook.com/me/status...ss_token=.....

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!
__________________
I fought the law...and the law won.

Last edited by kingthong; Jan 19, 2011 at 06:51 AM. Reason: url tags
kingthong is offline   0 Reply With Quote
Old Jan 20, 2011, 04:47 AM   #2
kingthong
Thread Starter
macrumors member
 
Join Date: Sep 2010
Location: 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 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

https://graph.facebook.com/id/statuses?access_token=...

where id = userId.

Hope this is clear.
__________________
I fought the law...and the law won.
kingthong is offline   0 Reply With Quote
Old Jan 21, 2011, 05:02 AM   #3
kingthong
Thread Starter
macrumors member
 
Join Date: Sep 2010
Location: 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.

Thanks.


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.
__________________
I fought the law...and the law won.
kingthong is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > iPhone/iPad Programming

Tags
api, connect, facebook, graph, iphone

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
Facebook status post idelovski iPhone/iPad Programming 11 Sep 4, 2013 08:47 PM
Receive Facebook messages sent while offline in Messages? LennyE Mac Applications and Mac App Store 0 Apr 22, 2013 05:55 PM
facebook status gone from notification bar white4s iOS 6 2 Nov 24, 2012 02:28 PM
Facebook Graph For Messages/Writing on Friend's Walls? newtoiphonesdk iPhone/iPad Programming 5 Jun 27, 2012 12:14 PM
FBLogout using graph API. never ask Login credentials again. goldenlife iPhone 0 Jun 5, 2012 08:08 AM

Forum Jump

All times are GMT -5. The time now is 03:55 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC