Ruby Facebook API批处理请求
我正在尝试使用Ruby同时获得多个URL的相同计数。我尝试过类似的方法,但似乎不起作用:Ruby Facebook API批处理请求,ruby,facebook,Ruby,Facebook,我正在尝试使用Ruby同时获得多个URL的相同计数。我尝试过类似的方法,但似乎不起作用: batch_get = [{"method"=>"GET", "relative_url"=>"method/fql.query?query=select total_count from link_stat where url='http://www.bbc.co.uk/news/world-us-canada-26233909'"}, {"method"=>"GET", "relati
batch_get = [{"method"=>"GET", "relative_url"=>"method/fql.query?query=select total_count from link_stat where url='http://www.bbc.co.uk/news/world-us-canada-26233909'"}, {"method"=>"GET", "relative_url"=>"method/fql.query?query=select total_count from link_stat where url='http://english.chosun.com/site/data/html_dir/2014/02/19/2014021900954.html'"}]
q = "select total_count from link_stat where url='#{batch_get}'"
fbreq = URI.escape("https://graph.facebook.com/?batch=#{q}")
JSON.parse(open(fbreq).read)
我可以得到单一的网址喜欢,但性能相当差,我想得到他们在一个请求。这是否可行
谢谢您不需要批处理此操作,它可以通过单个FQL查询完成:
select url, total_count from link_stat where url in ('http://www.bbc.co.uk/news/world-us-canada-26233909','http://english.chosun.com/site/data/html_dir/2014/02/19/2014021900954.html')
因此,请求将是
https://graph.facebook.com/fql?q=select+url%2C+total_count+from+link_stat+where+url+in+%28%27http%3A%2F%2Fwww.bbc.co.uk%2Fnews%2Fworld-us-canada-26233909%27%2C%27http%3A%2F%2Fenglish.chosun.com%2Fsite%2Fdata%2Fhtml_dir%2F2014%2F02%2F19%2F2014021900954.html%27%29&access_token=YOUR_ACCESS_TOKEN
工作得很好!谢谢:请记住,FQL现在在facebookapiv2.1+上是不受欢迎的,这是真的,但在撰写答案时,事实并非如此。此外,如果您有v2.0应用程序,您可以在2016年8月7日之前使用FQL。