开发者

Getting Facebook friends' locations is time consuming

开发者 https://www.devze.com 2023-04-05 15:18 出处:网络
In this algorithm I am looping through each friend to find their location, yet this is very inefficient... for 100 friends, this script takes over 2 minutes...can anyone suggest a more efficient solut

In this algorithm I am looping through each friend to find their location, yet this is very inefficient... for 100 friends, this script takes over 2 minutes...can anyone suggest a more efficient solution?

开发者_高级运维
@friends[1..100].each do |f| # 'f' contains basic friend info (name, uid)
  friend = get_friend(f['id']) # 'friend' gets data for each friend
  if friend.has_key?('location')
     @friends_locations[friend['name']] = friend['location']['name'] 
    end
  end

Im using Koala API and Ruby on Rails... thanks!


Try FQL instead u can query/queries by post it throught REST API too the query would be so ething like

select ... From user where hid in (select uid2 from friends where uid1 = me())


You can send 20 queries at a time using Batch Requests. But FQL is probably a better approach and I haven't heard that it is deprecated.

0

精彩评论

暂无评论...
验证码 换一张
取 消