Convert facebook photo url link to photo's graph api object id - facebook

Given a link to a facebook photo like this:
http://www.facebook.com/photo.php?pid=123&id=456
how can I get the internal facebook id for the photo? The "pid" in the link is not the "pid" in FQL in the "photo" table from what I've seen in my experimentation. The best I can think of is to read back all the user's photos using the userid (id=456) and look for a matching link URL but that is slow and clumsy. Is there a more direct approach?
Edit: this is the best I've been able to come up with, it works but it pulls a lot of data back if the user has many photos. It executes reasonably fast (1 second or so) so it's OK but I'd still like to know if there is a more direct approach:
SELECT link,object_id,aid FROM photo WHERE aid in (SELECT aid FROM album WHERE owner=456);
then search the results for a matching link with the "pid=123" substring
It turns out I also need the object id for the album and its size, so then I do a second query with the matching aid found from the first step:
SELECT object_id,size FROM album WHERE aid='<aidFromStep1>' AND owner=456;

not sure if it is what you want but if C# is the call then i have done this through following code
dynamic friends = app.Get("me/photos", parameters);
foreach (dynamic photoInfo in friends.data)
{
MessageBox.Show("Photo id is "+ photoInfo.id);
}

Related

Getting user profile pictures without FQL - graph api v2.2

I was using FQL to get all the photos in the user profile pictures album.
Since facebook decided to deprecate FQL in their latest version of graph api, im looking for the easiest and fastest way to get the user profile pictures (all of them)
I was using this FQL:
SELECT object_id, src_big, src_big_height FROM photo WHERE aid in (SELECT aid FROM album WHERE owner = 'XXXX' AND type = 'profile') LIMIT 20"
Any graph method that would get me the equivalent in 1 graph call? (I know i call call for /user/albums and to use the album id later to get the photos, but i don't want to seperate it to 2 calls)
Thanks alot
Ok, the best I could came up was using graph api field expansion:
https://graph.facebook.com/me?fields=albums.limit(1).fields(name,photos.fields(name,picture,source,images))
Im assuming the first album is the profile pictures.
Hope this can help others :)

Why doesn't the Graph API return the newest photos a user has been tagged in?

About a dozen users have complained that my app that fetches photos they are tagged in is not fetching the most recent photos... it is a simple call.
http://graph.facebook.com/me/photos
Is there any way to get the newest photos? Some sort of Order By? Or is there some kind of delay between tags and access via the API?
Any help would be appreciated!
I've seen some goofy stuff going on with the Open Graph API over the last week where objects that belong to a record are not getting returned with a valid API call. My issue went away on its own this weekend.
There is some delay in the best case between when an item gets tagged and it shows up on all the FB servers. The server that is serving your user's page to them will be different than the one serving the Graph API response. In my experience it is usually less than 30 mins, for the update but I've seen it take up to 6 hours.
As far as I can tell, you need to use an FQL call to explicitly order the results you get back.
You can get a list of photos with tags ordered by time by using this FQL query:
SELECT subject, object_id, created FROM photo_tag WHERE subject = USER_ID
where subject is the user id of the user who was tagged, object id is the id of the photo object, created is the creation time (as Unix timestamp), and photo_tag is the FQL table. This will return a list ordered by time with newest first.
From there, you can get the photo url using the object_id like this:
SELECT src, src_big, src_small FROM photo WHERE object_id = OBJECT_ID
which will give you urls to the photo in 3 differen sizes. This uses the FQL photo table.

Integrating Facebook with iPhone app - Performance issue using Graph API

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.

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"