0

I am developing a web application using Java. I need to access my friends photos and need to select the photo in which he is tagged. ( i.e ) His face should be there in that photo.

How to do it with Facebook Api's? I have searched and got few SO posts for taking profile picture of friends like this link1 link2, but I couldn't get anything related to accessing friends photos and getting their images in which they are tagged/ friends face is available.

Can someone help me out on how to accomplish the above case?

Community
  • 1
  • 1
2vision2
  • 4,933
  • 16
  • 83
  • 164

1 Answers1

1

See https://developers.facebook.com/docs/reference/fql/photo_tag/

To get links you have to run query like

select link from photo where object_id in 
    (select object_id from photo_tag where subject=me())

Of courset instead of me() you have to write your friend id.

Note, that

To read the photo_tag table you need the following permissions:
User:
user_photos permissions to access photo tag information that a user is tagged in.
friends_photos permissions to access photo tag information that a friend is tagged in.

BTW you will receive photos on which the person is tagged, but these photos may contain no real image of person.

user15
  • 1,044
  • 10
  • 20
  • Thanks for the reply. The query you have mentioned is not working. I am getting { "data": [ ] } as output. – 2vision2 Apr 07 '14 at 10:30
  • You have [] even if you provide subject=me()? – user15 Apr 07 '14 at 11:05
  • Yes I am getting the same even if I provide subject=me() – 2vision2 Apr 07 '14 at 11:09
  • Can you test the query from your end? – 2vision2 Apr 07 '14 at 11:18
  • yes, this query (in answer above) lists all links on photos I was tagged in. But it does not return photos where it is said "with XXX", only those where my face (or a point that pretends to be my face) is present – user15 Apr 07 '14 at 11:29
  • Is the given format wrong in the answer above? I have checked in two different accounts. – 2vision2 Apr 07 '14 at 11:44
  • It worked for me actually. Does this query `select object_id from photo_tag where subject=me()` work for you? If no, then user you're logged in under is not tagged anywhere. If you tag yourself somewhere will this query work? – user15 Apr 07 '14 at 12:26
  • No this query is not working for me.. **select object_id from photo_tag where subject=me()** I have checked in my friends account also, it is not working.. – 2vision2 Apr 07 '14 at 13:11
  • Do you run this query from FQL explorer? https://developers.facebook.com/tools/explorer/145634995501895/?fql=select%20object_id%20from%20photo_tag%20where%20subject%3Dme() – user15 Apr 07 '14 at 14:01
  • Sorry my mistake, I havent turned on the access tokens. Its working now. – 2vision2 Apr 07 '14 at 14:05
  • Thanks a lot for your patience.And Can I get another query to access my friends photo album? – 2vision2 Apr 07 '14 at 14:28
  • It should be like `select object_id from photo_tag where subject in (select uid1 from friend where uid2=me() )`, but you need permissions to receive results, otherwise you'll receive empty data[] array. – user15 Apr 07 '14 at 15:04