How to get total number of albums of all facebook friends? - facebook

How to get total number of albums of all facebook friends?
I want to retrieve all facebook friends total albums in one go.
Anyone have have idea how to query "album" table in FB
plz share ur thoughts thanks

I've came across this link earlier today, sound similar to your question
FQL for returning all album names and object id's of the albums for ALL friends of a user
If you removed the "LIMIT 25" as ifaour mentioned from his example side note, the query would look like this and do the task
SELECT aid, owner, name FROM album WHERE owner IN (SELECT uid2 FROM friend WHERE uid1=me())
2nd step: let's put it into a multi-query format
{"query1":"SELECT aid, owner, name FROM album WHERE owner IN (SELECT uid2 FROM friend WHERE uid1=me())","query2":"SELECT owner, album_object_id, object_id FROM photo WHERE aid IN (SELECT aid FROM #query1)"}
I guess you'll need to modify the fields in query2 to fit it into your scenario
These will return as 2 big fat json objects with 5000 results limit... which I haven't figured out a solution to query the next 5000 and the rest...
Also, I think there's a bug in both FQL and Graph API, some of my friends' albums are NOT showing in the result... (yes, with the right permission and necessary scopes to browse and query...) I've fired a bug report for this issue

Related

How to Get Share count of a picture while it says share_count is not a member of photo table

I am using this query and trying to get share count of each pic but it returns an error.
SELECT link, comment_info, like_info, created, pid, src_big FROM photo WHERE aid
IN (SELECT aid FROM album WHERE owner=20531316728)ORDER BY share_count desc
I do want to order the last 20 pictures with there share count. Can somebody help me how could I achieve this.
I am not writing an application. Just testing it in Graph API explorer v2.0 API in developer tools.
This isn't possible because there exists no share_count field in the FQL photo table. https://developers.facebook.com/docs/reference/fql/photo/

Retrieving friends photos with FQL

I am building a product which uses images from a users Facebook friends. I have found multiple examples on SO which filter the photos by filtering through albums and the users friend list like this:
SELECT pid, link, owner
FROM photo
WHERE aid IN
(SELECT aid FROM album WHERE owner IN
(SELECT uid2 FROM friend WHERE uid1=me())
)
But why can I not skip the album collection? The following should work, but running it in the Graph API Explorer never returns a result (like a timeout which never occurs):
SELECT pid, link, owner
FROM photo
WHERE owner IN (SELECT uid2 FROM friend WHERE uid1=me())
AND created > strtotime("10 February 2013")
ORDER BY created DESC
The token I am using most certainly has 'user_photos' and 'friends_photos'. Using the regular graph explorer also has the same behaviour, no result is ever shown:
Is this an error in my logic, an error with the Facebook platform, or is there something odd going on here?
Speaking about:
SELECT pid, link, owner
FROM photo
WHERE owner IN (SELECT uid2 FROM friend WHERE uid1=me())
AND created > strtotime("10 February 2013")
ORDER BY created DESC
First, this query times out.
Second, a FQL query can only gives 5000 results, whereas our friends have uploaded far more photos than that.
Third, you tried to improve a first query which doesn't work (in my case, it only found 1470 of my friend's photos).
Fourth, even if your second query wouldn't time out and if it could give more than 5000 results, this query wouldn't give all the photos of the user friends. Because this query:
SELECT pid, link, owner
FROM photo
WHERE owner=USER_ID
only gives the last 100 photos of the user, whereas the user could have 2000 photos for instance.
So at least, we don't have to correct your query, but we should try to make a new one. The goal is not to make the less queries as possible while making complicate queries, but to make something clear that works.
At first, let's try to get all the photos of one user.
SELECT pid, link, owner
FROM photo
WHERE owner=USER_ID
AND created > strtotime("10 February 2013")
ORDER BY created DESC
LIMIT 5000 OFFSET 0
Now we don't get 100 photos anymore, but 5000!
Secondly, we get all the friend users:
SELECT uid2 FROM friend WHERE uid1=me() LIMIT 5000
The max amount of friends for a user is indeed 5000.
Now, all you have to do is:
to make one request that gets the user friendlist.
to loop onto each friend and to make one request for each of them in order to retrieve their photos. IF the amount of photos is not less than 5000, it means that the user still have some photos to show. You'll then have to make another request while incrementing the OFFSET by 5000!
Now you are sure to get all the user friends photos! Also, having this procedure cut up into multiple smaller requests is not a bad thing; you'll be able to know the progress of the query which you can render as a progress bar in AJAX for example. It might be a good thing because it will take a lot of time!

Using the Facebook Graphi API, how can I retrieve paginated photos in which my friends are tagged from a specific album?

I want to show the photos of an album in my app. Using the graph API i am able to filter and page by month, like below, which is great. I loop trough the results and get the photo for each id. Best of all, the GRAPH API also gives me a 'next' and 'previous' paging link. Very useful.
http://graph.facebook.com/[photo-album-id]/photos/?fields=id&limit=6&since=last month
But now i want to retrieve only those ids filter in two ways:
Only retrieve those in which the user is tagged
Only retrieve those in which the user & his/her friends are tagged.
I couldn't find any way to do this, with the graph API. Is there an alternative via FQL, that still has the paging in there?
Last alternative I can think of is program is in FQL, and do the paging myself.
p.s. I am doing this in Javascript currently.
You can retrieve photos the current user is tagged in in a specific album with this FQL call:
select object_id, src, album_object_id from photo where pid in (select pid from photo_tag where subject=me()) and and album_object_id=somenumber
To retrieve photos in which the user's friends are tagged, for a specific album:
select object_id, src, album_object_id from photo where pid in (select pid from photo_tag where subject in (select uid2 FROM friend WHERE uid1 = me())) and album_object_id=somenumber
As far as I know these results will not be paginated. For a detailed take on how to paginate fb queries see the Facebook Developer Blog: How-To: Paging with the Graph API and FQL
After a little play with the Graph Explorer (https://developers.facebook.com/tools/explorer/) I come up with this solution. You can make a call to Graph API as follows
/me?fields=friends.limit(5).fields(photos.limit(5))
The first limit is for how many friends you want to get and the second limit is how many photos you want from each friend.
At the end of the data there already is the next page URL.
I only tested on the explorer but should work.
Hope that helps,
Doruk

Facebook Graph - getting my pictures

I'm looking for the fastest way to get all the pictures I'm tagged in with someone specific.
As for now I need to check "my photos" then "the other someone's photos" and then photos in albums of all my friends.
it takes forever.
I need a way (I guess it's an FQL request) to get all the photos me and a specific friend are tagged in together?
Getting some of the photos easy to do with an FQL Query:
SELECT object_id, src, owner, caption, created
FROM photo
WHERE object_id IN (SELECT object_id FROM photo_tag WHERE subject = me())
AND object_id IN (SELECT object_id FROM photo_tag WHERE subject = 'MY_FRIENDS_ID')
(In this example MY_FRIENDS_ID could also be an event id or a group id)
Facebook has limits on the number of objects returned by an FQL query. To get all of the items, you'll have to write a script that appends AND created < {OLDEST_DATE_RETURNED_BY_LAST_QUERY} to your FQL and repeats the query until no data is returned.
Demo query here of photos you are tagged in: https://developers.facebook.com/tools/explorer?method=GET&path=fql%3Fq%3DSELECT%20object_id%2C%20src%2C%20owner%2C%20caption%2C%20created%20FROM%20photo%20WHERE%20object_id%20IN%20(SELECT%20object_id%20FROM%20photo_tag%20WHERE%20subject%20%3D%20me())

Get all youtube links shared by current user's facebook friends from the past hour

I am trying to get all youtube links shared by current user's facebook friends from the past hour.
I have found an FQL script that would get the latest 100 links shared by the current user's friends but I am trying to query only for youtube links and for the past hour instead of a limit of 100.
This is the script that I have found. How can I change it?
select link_id, title, url, owner, owner_comment, created_time, picture from link where owner in (select uid2 from friend where uid1 = me() LIMIT 100) ORDER BY created_time DESC
You may have found a limitation of the Facebook API. Was there any pagination information in your response that would allow you to page thru the results?