like table doesn't have all the likes done by the user - facebook-graph-api

I am trying to fetch all the likes that a user has done. I am using the following fql queries to fetch the likes.
SELECT object_type, post_id, object_id FROM like WHERE user_id=me()
I am passing the user's access token along with this query.
Some of the user's like activity is not reflecting in the like table. Did some tests and found out that the missing ones are the likes on posts of some specific friends.
I haven't yet figured out if there are any other like activities of the user that is missing from the like table.
What are the rules by which a like activity of a user is recorded in the like table?

It seems Facebook does not gives accurate Like results, at first thought it was caused by users privacy settings, but doing some test with my own friends, the API still shows a discrepancy between the like total_count and the amount of like objects returned. It's either a bug or a mysterious deliberated decision by Facebook.
Please check these other people asking something similar:
Difference between a post's likes count and the likes data?
Facebook Graph API and FQL like count on photo's both incorrect?
Facebook wall post likes are not counted in fql query

Related

Facebook Graph API get likes/reactions

I'm trying to fetch some data from page posts on Facebook with the Graph API. I'm using Python normally but I try the queries first with the Exploration tool offered by Facebook.
I used the page_id + post_id to get the number of reactions (I would also like to get the count for each different reaction) and likes. But it just returns nothing. I get the data for the shares though. I have the post open on another tab and it has likes and reactions.
Don't know what I'm doing wrong.

Facebook graph API does not return all posts for user

I am trying to get all user posts through Facebook graph API. But never get all of it.
When I tried it through the path: "me/posts" (with param limit=5000), I get all of the posts that wrote by the user (like I wanted), but not before specific date. Mean, in this way I am not getting any of the posts before specific date (in my case it was not before 29/01/2011).
When I tried it through the path: "me/feed" (with param limit=5000), I get all kind of posts from my profile wall even posts that not the user wrote and posts from start of my Facebook (2007).
But, this result is missing some of my posts through time. When I roll in my old post on my profile page I can see many posts that I wrote but its not in the result.
When I tried it through the fql:
"SELECT post_id, actor_id, created_time, updated_time, action_links, permalink, message, action_links FROM stream WHERE source_id = me() LIMIT 5000"
I get the same result as when I tried with the path: "me/feed". And the same missing posts is missing.
Is anybody else had this problem too?
Update:
I am sorry that I wasn't clear enough. My interest is only on the posts that current user wrote, not on his friends posts. I know that sometimes I can get from Facebook only mixed posts - like when I ask for the path: "me/feed". But, my intention was to filter them on my server.
The posts that missing from the data (and I can see on my wall) is my post, not my friend's posts.
This could happen when your friends have set their privacy settings so that their posts aren't made available via the Facebook platform. That's probably why you are seeing the difference.

Getting users who like a web page with Facebook graph API

I'm struggling with the Facebook API. What I want to do is to be able to look at a user's feed, see which web pages they clicked "Like" on, and then get the other users who like the same web page. I'm having two problems.
1) Whenever I get the feed of a user, all of the "Likes" are removed from the feed. Its very frustrating because its like Facebook will give me everything except for exactly what I'm looking for!
2) I can't seem to get a list of user IDs who like a certain URL. I've tried using FQL like this:
SELECT user_id FROM like WHERE object_id=114324145263104
As was suggested in another SO question, but that returned nothing on all of my attempts.
Does anyone know how to do this, or if its even possible? Thanks for your help!
There is a different query for getting the linkes of a url
SELECT url FROM url_like WHERE user_id = me()
In your case it is.
SELECT user_id FROM url_like WHERE url = "http://www.domain.com/"
I had the same problem. This is what i do
https://graph.facebook.com/URL
OR if you have multiple URLs click to
https://graph.facebook.com/?ids=URL1,URL2,URL3

FQL query for photos returns photos from hidden (blocked) users. How to prevent this?

I request latest photos for a user using an FQL query, like the one below:
SELECT pid, aid, owner, src_small, src_big, src, link, caption, created FROM photo WHERE aid IN (SELECT aid FROM album WHERE owner IN (SELECT uid2 FROM friend WHERE uid1=) ORDER BY modified_major DESC LIMIT 300) ORDER BY created DESC LIMIT 500
It works well but I believe it doesn't respect the setting where the user block specific users on the facebook page. So in my app, he sees all the photos, and he's not happy :).
Now, I see that in user table there's is_blocked property, but it's not indexed so I can't use it in a WHERE clause. I also don't want to call FB for every user I get just to check for that property and filter based on that in the app itself.
So, first of all, am I correct that this query doesn't respect blocked users settings?
If yes, is there a way to respect this setting using FQL?
You may look at privacy table. There is id column which represent an image object as well and deny field with a list of users that cannot see the object. I think you should use a fql.multi-query to resolve this. Some info about fql.multi-query you can find at this topic.

Get Facebook "Like" count for every page on my domain

I have integrated the Facebook "Like" button into a lot of pages in my site. I want to display the most "Liked" pages on my site in a list, but I can't figure out how to get that data from Facebook in one request. So far, I have been able to get the "Like" count for individual pages using the following FQL query:
SELECT share_count, like_count, comment_count, total_count
FROM link_stat
WHERE url="http://www.mysite.com/some-page"
However, getting the count for each page on my site one at a time is not really feasible. Aside from having a large number of pages, new pages are being created constantly (new user profiles, new blogs and blog articles, etc), which would make getting complete statistics for my site a complicated process and would involve calling Facebook's API thousands of times.
Is there a way to get a count of how many times each page on my domain has been "Liked" in one request? Or just the top 10 most "Liked" pages, or something similar?
Actually I would do it this way:
$arrayOfPages = array('url1', 'url2', 'url3');
$listOfPages = implode(',', $arrayOfPages);
SELECT share_count, like_count, comment_count, total_count, url
FROM link_stat
WHERE url IN ($listOfPages)
That would give you all the data with the URL as a unique identifier without having to break Facebook's policy against fake users. You can dynamically create the $arrayOfPages variable from a query on your site's database.
In continuation to Salil's answer, here are the some of the major APIs sharedcount.com are using (full list here: http://sharedcount.com/documentation.php)
You can use sharedcount's API to get a general summary, or write something yourself using the APIs:
Facebook: http://api.ak.facebook.com/restserver.php?v=1.0&method=links.getStats&urls=%%URL%%&format=json
Twitter: http://urls.api.twitter.com/1/urls/count.json?url=%%URL%%&callback=twttr.receiveCount
Google +1 +1 counts are retrieved via a JSON-RPC POST call that requires an API key (To get a google API key - https://developers.google.com/+/api/oauth#apikey):
POST URL:
https://clients6.google.com/rpc?key=%%API-KEY%%
POST Body:
[{"method":"pos.plusones.get","id":"p","params":{"nolog":true,"id":"%%URL%%","source":"widget","userId":"#viewer","groupId":"#self"},"jsonrpc":"2.0","key":"p","apiVersion":"v1"}]
It will be difficult to get FB likes for all your pages in one query, but you can get individual share count for every page of your site. Apart from the share count you can also get the breakup of numbers for individual social network for which your site page is shared. Insert you domain name at http://sharedcount.com/?url=http%3A%2F%2Fwww.parasitech.net%2F with appropriate suggestions provided to you. You can get numbers for Facebook, Twitter, Google+, Diggs, Linkedin, Google Buzz, Delicious and StumbleUpon.
Apparently there's no 'LIKE' in FQL. Which was my first suggestion..
Though you can use the "IN" operator, like so:
SELECT share_count, like_count, comment_count, total_count
FROM link_stat
WHERE "http://www.mysite.com/" IN url
ORDER BY like_count
LIMIT 10;
1) create a fake user on fb which will likes only pages from your domain or some other way to save your urls in fb with possibility to get them by FQL later
2) query:
SELECT share_count, like_count, comment_count, total_count
FROM link_stat WHERE url in (SELECT object_id FROM like WHERE user_id="fake_user_id")
3) don`t forget about decrement on 1 each like count ;), sort and show
Maybe you can just query the number of likes for each page each time the page is viewed. This won't be precise, but keeping in mind that the most popular pages will be viewed more often it might be good enough.
Additionally, you can use a batch process to query the number of likes of all the page or at least the top N last created ones every couple of hours. Most of the time you won't get the correct result, but in most cases your users don't need the correct result but a good enough approximation.
If you just need the count from every page, Super Social Media Tracker could provide that.
http://apps.microsoft.com/windows/en-US/app/super-social-media-tracker/a56c8971-42e2-4eb4-9b05-7e52233b4e1e
But it's slow for massive pages.
After some looking around, we may be better off using FQL with graph API:
http://graph.facebook.com/fql?q=select%20comment_count%2C%20share_count%2C%20like_count%20from%20link_stat%20where%20url%20%3D%20%22http%3A%2F%2Fmashable.com%2F2013%2F01%2F30%2Ffacebook-twitter-blackberry-10%2F%22
Results are
{
"data": [
{
"comment_count": 3,
"share_count": 91,
"like_count": 5
}
]
}