3

I admin a certain facebook page.I am trying to get urls of posts with 1000+ likes.

I dont need to retrieve data for using it in app.I would want to manually copy paste links of posts with 1000+ likes from the output we get from Graph API explorer.I am a bit new to this.

I have tried searching in API docs for such query which filters as per like,but in vain.All i could find is how to retrieve all posts using this

https://graph.facebook.com/ilovetrolls/posts?access_token=

Is there any such query which lets us filter as per likes?

3 Answers 3

3
+500

You can probably use fql and you want a query like:

SELECT post_id, comments, like_info.like_count, message 
FROM stream
WHERE source_id = 263738183707778 and like_info.like_count > 1000 and created_time > 1325376000

replace 1325376000 with the start time you want (given in a unix time stamp format here, for reference see http://en.wikipedia.org/wiki/Unix_time, this is currently set to 1st Jan 2012 00:00:00

the url it generates that you need to use is:

https://graph.facebook.com/fql?q=SELECT post_id, comments, like_info.like_count, message FROM stream WHERE source_id = 263738183707778 and like_info.like_count > 1000 and created_time > 1325376000&access_token=

using soemthing like limit = 50 will help fetch more posts. The number of posts is limited by what I read is a bug in the fql api. See Facebook FQL stream limit? Facebook FQL `like` table retuns max 100 rows?

The recommended thing to do is use the graph api instaed. Unfortunately the graph api doesn't have a straight way to filter based on number of likes.

One thing to possibly do is change the date range and run in a loop example where you iterate over date ranges setting an upper and lower limit for the created_time and either run it in a loop or perform a batch query

If you want to do it more reliably try something likes this (the following is a python script): replace YOUR_ACCESS_TOKEN_GOES_HERE with your access_token

import urllib2
import json
access_token = 'YOUR_ACCESS_TOKEN_GOES_HERE'
request = urllib2.Request('https://graph.facebook.com/263738183707778/?fields=feed.fields%28likes.summary%28true%29.limit%281%29%29.limit%28500%29&access_token='+access_token)
data = urllib2.urlopen(request).read()
data_parsed = json.loads(data)


for a in data_parsed['feed']['data']:
    if 'likes' in a:
        if int(a['likes']['summary']['total_count'])>1000:
            print a['id'].replace('263738183707778_','https://www.facebook.com/ilovetrolls/posts/')

data_parsed = data_parsed['feed']
while 'paging' in data_parsed:
    request = urllib2.Request(data_parsed['paging']['next'])
    data = urllib2.urlopen(request).read()
    data_parsed = json.loads(data)
    for a in data_parsed['data']:
        if 'likes' in a:
            if int(a['likes']['summary']['total_count'])>1000:
                print a['id'].replace('263738183707778_','https://www.facebook.com/ilovetrolls/posts/')
Sign up to request clarification or add additional context in comments.

8 Comments

Thanks a lot for your ans....any tips whats this error? img.ctrlv.in/img/52c04e15eaf53.jpg
Alternatively you could look at fetching posts with the graph api and getting a summary of likes then later filtering them by number of likes. This will just ensure that you get all of the posts.Which language are you writing your code in?
how to do that?English
lol....i feel so dumb....I am not writing the code for use in any app or something.....i just need to get a list of urls manually. :)
let me know if you need any more help
|
1

Facebook Graph API doesn't provide any such feature. Only way to do that is by using FQL query. You can use the following FQL query to retrieve this information:

SELECT post_id, like_info.like_count 
FROM stream WHERE source_id = {Your Page Id} 
and like_info.like_count > 1000 LIMIT 50

For example, the following query will return the posts which received more than 1000 likes for your page:

SELECT post_id, like_info.like_count 
FROM stream WHERE source_id = 263738183707778 
and like_info.like_count > 1000 LIMIT 50

NOTE: Using LIMIT 50 at the end of your FQL query will return greater number of posts in the output as compared to a normal query. I don't know the reason behind this. In fact, I believe that it's just because of the strange behavior of the Facebook API.

2 Comments

Seems the limit is around 500...can't help maybe....is there any way to select post url instead of post_id :) ?
If you are doing it manually, you just need to add the last 15 digits of the post_id to the URL https://www.facebook.com/ilovetrolls/posts/. For example, if the post_id is 263738183707778_567657616649165, then URL for that post would be facebook.com/ilovetrolls/posts/567657616649165.
0

You cant only do it through FQL query. So you can use this URL. Or Write your own FQL query in the input place.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.