Integrating Facebook with iPhone app - Performance issue using Graph API - iphone

I am having a performance issue using the Facebook Graph API to pull a user's friends list. My issue is not in retrieving the list, but having to loop through the list once it is retrieved to get the user's picture.
The "me/friends" api call only returns the userId and userName. I then have to take each persons userID and make a call to get their picture. This slows down my UITableView of friends quite a bit.
Does anyone have a better solution to load all of the pictures?

I guess, the problem should be because you must be loading all the images at once and that will block UI until all the images are downloaded for visible table cells images. That can be resolved by implementing Lazy Loading. That is sample provide by APPLE itself so you can check code and use it as per your requirement.
Let me know if you stuck any where.
Hope this helps.

as far as i know, you have to do your stuff as u did. you have to use to GRAPH API to retrieve user's friend's photo.
First use the FriendList API to get the friend list, then get your friend's photo using Photo API.
I assume, you have done this way. One thing may be you can try is using AsynchronousImageView. Use AsynchronousImageView in your tableView to load the images asynchronously, so that it will not get stucked when loading the table view.

To get their photo, you can construct it with a common URL (this is unique for pictures only). You are limited to the small one, though. So for the big ones, you need to use FQL to do a structured query. But that is a good option, and would work fine. FQL is a little awkward syntactically. You can test it in graph api explorer before popping into Xcode.
The options:
The picture url can be constructed as:
NSString *url = [[NSString alloc] initWithFormat:#"https://graph.facebook.com/%#/picture",objectID];
FQL query (this is a common one)
SELECT uid, name, pic_square FROM user WHERE uid = me() OR uid IN (SELECT uid2 FROM friend WHERE uid1 = me())
But honestly, why do that when you can use the graph to get friend uids and construct the picture on the fly- except, of course, if you want a larger picture.

Related

Get recent photos from the Facebook v2.1+ graph api

Facebook's FQL was deprecated after v2.0. The website I'm working on previously had a "Recent photos" feature that populated recent photos using this FQL:
var fql = 'SELECT object_id, aid, images, album_object_id, created, modified, position, caption
FROM photo
WHERE aid in (SELECT aid, owner FROM album WHERE owner = me())
ORDER BY created DESC
LIMIT 59';
I'm trying to figure out a comparable way to do that using the graph api. the /photos endpoint is probably what I want, but I can't figure out if it has a valid order queryparam.
In postman I've been messing around with this:
https://graph.facebook.com/v2.2/10151316456544622/photos?fields=picture,name,source,created_time&limit=20&order=-created_time&debug=all&access_token=CAAL7TZAyo4RUBAOJe4Jgjdt6NZAqcajRghEGdKwraq4X1yZAKjvgXj4xXAZCoyZCkzMO84mTMJ90Vp5CEfJsT1WsoOwif2QZCS00bGqZAVxqmZChMUqKQmNsu2DvZCoY42ZC5fSBAxUuNCqTWg1QZCBZCz5oQx3wcNZCZCPUHOXMu5i5jZCOTGIiPWrAeTlzhFBqkvoZBZAPSJRhlkdxyrKPmpmOqgKrUeD13TdOtKU4ZD
The access_token is of a FB test account, feel free to go nuts. I'm not getting any debug information. There doesn't appear to be anything in the docs about how to change the order of photos.
This example url might not be the best. There's only 7ish public photos for this account, but I will potentially be getting recent photos from accounts with 1000s of photos. I don't want to just get all photos and reverse the list. I want to the most recent 20 photos in one call.
Any ideas? Is there order documentation that I've missed?
There is no direct way to achieve this using the Graph API, but you can use Real Time Updates to get notified about changes to the photos of a user.

How to get the facebook photo from fbid using FQL?

It is weird sick in this situation. I know the answer but it does not work.
I use php to write a photo upload system. The picture will upload to facebook from my server and it return me the fbid. So I can use this fbid to run a FQL to get the photo's different size. The FQL is:
SELECT src_small, src_big, images FROM photo WHERE object_id=[fbid]
This work good in my php system. It return an array that contain different picture size of url. I save them in database including the fbid. Sometime it get NoPic words, so I decide to check this photo array from facebook. I run the FQL in my system again and also try the facebook graph API tools. Both of them return empty array set.
Then I use the facebook link to check if the object exist, it work.
https://www.facebook.com/photo.php?fbid=220817144722724
This means the object exist, but I cannot get it from FQL anymore...
How can I get it again?
If you successfully uploaded your photo, it means that you undoubtedly set the photo_upload permission. Unfortunately, this permission only allows you to POST photos, but not to GET them.
Therefore, I suppose you forgot to set the user_photos permission. Or perhaps didn't you set it at the right place or wasn't it re-used by your FQL query?
That must be it, because I tried it and everything is OK on Facebook's side.

How do I get a list of friends who clicked "Like" on an external page?

PART A -
There are many many questions like this, but none of them seem to provide a working solution. I want to get a list of friends who clicked the Facebook "Like" button on an external site.
NOTE: This is NOT for a Facebook page. In this case, I know I can query the page_fan table.
To get the list of Facebook page-likes for example, I can use the url_like table. I guess I just want a way to invert this table. I know I cannot get a list of ALL people that liked a link due to privacy concerns, but I want a list of my friends alone - which should be fine.
I know facebook does this internally every time I see a Facebook Like button... right below that there is statistics about my friends that also like the same link. How do I get this using FQL?
PART B
Equivalently, how do I get a list of friends that shared a specific URL as a link? I cannot search the link table by url because that is not indexed. Also, the link_id is not the same as the Open Graph ID of the URL.
I tried select link_id from link where url="http://urladdress.com/a/b.html" and owner in (select uid2 from friend where uid1=me()) but that neither throws an error not returns anything... just stalls.
Part A: you can't.
Part B: you can't the way you are trying. You might be able to get the feed for every one of the users friends and look for that url from their feed, but it will be painfully slow.
Lots of people would like to know this but Facebook is (rightfully so) not giving this information out. That is why you see lots of questions regarding it but no working solutions.
You could possibly look into the read_insights permission. You might not be able to get the exact information about "likes" (yet)... but you will be able to get other possibly useful information.

Facebook FQL API - Who tagged user?

I am able to retrieve tags on statuses and photos just fine. I know the fact that my user has been tagged.
For posts, (stream_tag) it's easy to assess who did the tagging since the author of the status is by definition the tagger.
I am using FQL to query photo_tag table to obtain a pid and then querying the photo table to get photo information...
However, I am trying to ascertain who is the tagger of a user in a photo. People can tag other peoples photos, and I get all that, but I would like the attribution....
Thanks!
I don't think you can. Looking at a photo on Facebook doesn't show who added each photo tag; it makes sense that the API doesn't give you this information either.
you cannot read the tagger info, unfortunately. first, because you donĀ“t even see it on facebook directly. and there is no column for this info in the photo_tag table:
http://developers.facebook.com/docs/reference/fql/photo_tag/

How to get category specific likes for a facebook user using graph API

I'm pretty new at this. I was playing with the Facebook Graph API and was able to pull all my LIKES using the call
$all_likes = json_decode(file_get_contents('https://graph.facebook.com/me/likes?access_token='.[access_token]));
Now when I display these, they have a field called category which has different values like TV Show, Book, Public Figure etc.
So my question is how do I get category specific likes - for instance I just want to fetch ALL the BOOKS that I LIKE
Obviously its possible to fetch all the likes and store them on the server side and work on it but the LIKES list is too huge for certain users and it doesn't make sense to pull everything if you just want to show a certain category.
I feel like I'm missing something.
If its not possible through the graph API call, then even a FQL solution is welcome.
Thanks for your time
R
You can use FQL, just like in this answer:
SELECT page_id FROM page_fan WHERE uid=me() AND type="MOVIE"