I want to find which photo, video, status or other objects I liked in facebook.
Earlier I used fql to search in the like table:
SELECT object_id FROM like WHERE user_id=me() LIMIT 5000
But, in facebook api 2.1, fql is no more supported, so I need to use graph api to replace the above fql.
So, how can I use graph api to get my likes in facebook?
And I need to find who posted those objects also. In fql I used:
SELECT uid FROM status WHERE status_id IN (SELECT object_id FROM like WHERE user_id=me() LIMIT 5000) ORDER BY uid LIMIT 5000
I nee Graph api for the above fql also.
Plese help!
Just call the endpoint "<userid>/likes". This will give you the information. You need the proper permission for it though: "user_likes".
Related
Facebook FQL is deprecated. I'm currently using it to get the total sum of likes / comments photos have.
I'm doing something like this:
$q = "SELECT like_info, object_id, comment_info FROM photo WHERE object_id IN(".implode(",", $object_ids) .")";
Now that FQL is deprecated, how can I do the same with the graph API ?
This is quite easy with the Graph API:
/{photo-id}?fields=likes.summary(true),comments.summary(true)
I want to get all the posts from all the pages from the user /me/home feed.
Right now Facebook is deciding for the user what posts will get to the feed and which ones will not.
For example, if the user is subscribed (likes) 100 pages and all 100 of them posts an update the user feed will not show all 100 of them, only a portion of updates that it thinks important. Neither the API.
Is it possible to get all updates using the Graph api (like a regular timeline)?
You can try FQL, for example:
{"query1":"SELECT type,post_id,created_time,actor_id,target_id,message,attachment.media,attachment.caption,attachment.name,attachment.description,attachment.fb_checkin,likes.count,likes.user_likes,likes.can_like,comment_info,description FROM stream WHERE filter_key='pp' AND created_time<now() ORDER BY created_time DESC","query2":"SELECT id,name,pic FROM profile WHERE id IN (SELECT actor_id,target_id FROM #query1)"}
The keyword was filter_key='pp', means that you want to get all page's news feed.
I have no idea it will include ALL of 100 pages on real time, however this should be enough to achieve your goal. One more point, news feed have 1 week limitation, means that you cannot query older than 1 week's news feed.
Update:
https://graph.facebook.com/me/home?filter=pp is alternative way if you don't want to use FQL.
Use the following FQL in your https request to get the list of all likes paginated
SELECT src_big, src_small, owner,caption FROM photo WHERE object_id IN (SELECT object_id FROM like WHERE user_id == me() LIMIT 10 OFFSET 8 )
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
I have successfully retrieved the comments on a specific link using the fql with the following code:
{\"comments\":\"SELECT fromid, text, time, comments FROM comment WHERE object_id IN (SELECT comments_fbid FROM link_stat WHERE url ='http://permalink')\", \"users\":\"SELECT name, id FROM profile WHERE id IN (SELECT fromid FROM #comments)\"}
I want to post new comment and I have the access token of the user, what is the right way to do this using fql?
As far as I'm aware,you can't insert using FQL. FQL is merely a query language used to perform more complex queries than the Graph API endpoints offer allowing you to perform joins etc (Not joins in the traditional sense but using "IN" statements).
You would need to use the graph api and issue a POST request as detailed towards the bottom of this page https://developers.facebook.com/docs/reference/api/link/
I know both the old Facebook REST API and the new Graph API fairly well. Through the graph api and given maximum permissions I can request a user's photos (its my app and my account):
client.Get("/me/photos");
This returns an array of json encoded graph api photos. The only problem is that it's not the total number of photos in the account. I checked this by painstakingly counting my facebook photos AND comparing it against a simple call from the old REST API:
select pid from photo where aid in (select aid from album where owner=me())
(the above from memory, but what I had worked well)
My count and the REST API confirm that the graph API is NOT returning all the photos in the account (I know about paging as well).
Does anyone know why this is? Also, does anyone know how to convert an old REST API pid (photo id) to a new GRAPH API unique ID. It's the only way I can think of to get all the photos.
FQL is still available in the Graph API
https://graph.facebook.com/fql?q=select pid from photo where aid in (select aid from album where owner=me())
Also, there's another property called object_id on the photo fql table which should correspond (if memory serves) to the id in the photo api table
https://developers.facebook.com/docs/reference/fql/photo/
https://developers.facebook.com/docs/reference/api/photo/
Try:
https://www.facebook.com/photo.php?pid=11504724&l=3f088bdde4&id=99984862969
https://graph.facebook.com/fql?q=select object_id from photo where pid="99984862969_11504724"
Response should be:
{
"data": [
{
"object_id": "10151373634447970"
}
]
}