Take the 2-minute tour ×

Given a link to a facebook photo like this:


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;
share|improve this question
which lang c#? if yes desktop or web app –  Afnan Bashir Mar 30 '11 at 20:11
I just need the graph or FQL queries, I can adapt the query to the langauge I need. Command line with "curl" would be great. –  Bogatyr Mar 30 '11 at 20:19

1 Answer 1

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);
share|improve this answer
I specifically need to start withe the given link, and from there get to the object id of the photo, as stated in my question, so I don't see how that helps –  Bogatyr Mar 30 '11 at 20:18

Your Answer


