Wai Mun
Wai Mun

Reputation: 194

FQL get like count from friends in links

This might sounds complicated.

I want to retrieve links from my website whereby those links are liked by users and my friends. But I want to sort result by number of my friends' like count.

I have checked in link_stat and it provides a general stat only.

Is this possible to do?

Upvotes: 2

Views: 710

Answers (1)

cpilko
cpilko

Reputation: 11852

I thought I had an answer for you. I don't and I'm not sure why.

I shared a bunch of links yesterday to test a Like Button I implemented on a site. I thought this would be an easy question to answer. After playing with this for about 30 mins, I've come to the conclusion that it's not.

Looking at /me/feed in the API explorer, my links are there with "type": "link". However when I look at me/links or run an FQL query SELECT link_id, owner, url FROM link WHERE owner = me() ORDER BY created_time DESC those links aren't there. Bug report posted

Anyway, you should be able to start with an FQL query something like this:

SELECT link_id, owner, url FROM link 
   WHERE owner IN 
     (SELECT uid2 FROM friend WHERE uid1 = me()) 
     AND strpos(url, 'mysite.com') >= 0

Pass those link_ids via a Multiquery to the like table. FQL doesn't have a count method, so you'll have to count the likes and sort your results it in your script.

Good luck.

Upvotes: 1

Related Questions