Facebook FQL Multi.Query:连接结果集
我正在使用 Facebook 的 fql.multiquery 来处理许多不同的事情,并且我得到了结果 - 正如医生所吩咐的那样。但我似乎不知道如何加入结果,以便我可以按照我想要的方式将它们返回给用户。
我正在使用 HTTParty 来称呼它:
checkin_query = {
"user_checkins" => "SELECT timestamp, coords, tagged_uids, page_id, post_id, checkin_id, message FROM checkin WHERE author_uid= me()",
"location_names" => "SELECT name FROM page WHERE page_id IN (SELECT page_id FROM #user_checkins)",
"friends_with" => "SELECT uid, name, pic_square FROM user WHERE uid IN (select tagged_uids FROM #user_checkins)"
}
params = {:queries => checkin_query.to_json, :access_token => user.token, :format => :json}
@checkin_info = HTTParty.get "https://api.facebook.com/method/fql.multiquery", :query => params
这给了我我想要的东西......但它在 3 个单独的数组/哈希中(?)并且出于某种原因,我的大脑没有得出结论关于如何处理它。
所以基本上,如果我想向用户展示“好吧,伙计,你和这些人在 *LOCATION_NAME*:*FRIENDS_WITH*
我怎样才能获取这 3 个单独的结果集并匹配所有内容?有没有办法包含以前的内容 来回调并匹配它,以便我可以显示所有内容?有些签到没有 tagged_uids,所以显然,当涉及到他们所在的朋友时,仅按顺序执行是行不通的。
查询 JOIN(这看起来可能是一个解决方案) - 但在 FQL 中不可用。
I'm using Facebook's fql.multiquery for a number of different things and I'm getting the results back - just as the doctor ordered. But I can't seem to wrap my head around how to join the results so I can give them back to the user in the way I want.
I'm using HTTParty to call this:
checkin_query = {
"user_checkins" => "SELECT timestamp, coords, tagged_uids, page_id, post_id, checkin_id, message FROM checkin WHERE author_uid= me()",
"location_names" => "SELECT name FROM page WHERE page_id IN (SELECT page_id FROM #user_checkins)",
"friends_with" => "SELECT uid, name, pic_square FROM user WHERE uid IN (select tagged_uids FROM #user_checkins)"
}
params = {:queries => checkin_query.to_json, :access_token => user.token, :format => :json}
@checkin_info = HTTParty.get "https://api.facebook.com/method/fql.multiquery", :query => params
Which gives me what I want... but it's in 3 separate arrays/hashes (?) and for some reason, my brain isn't coming to a conclusion on how to deal with it.
So basically if I wanted to show the user "OK dude, you were at *LOCATION_NAME* with these people: *FRIENDS_WITH*
How can I take those 3 separate result sets and match everything up? Is there a way to include something from a previous query to call back and match it so I can display everything? Some check-ins have no tagged_uids, so obviously just doing it in order won't work when it comes to the friends they're with.
Google searches have shown me SQL's JOIN (which seems like it may be a solution) - but isn't available in FQL.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我没有使用 FQL 或 HTTParty 的经验,所以我可能完全错误。
我倾向于将sql格式化如下:
location_names和friends_with可能作为散列数组返回:
不确定HTTParty返回什么,但如果它是散列数组的散列,你可以尝试:
要弄清楚@checkin_info返回什么,你可以尝试这个:
I have no experience with either FQL or HTTParty so I might have this completely wrong.
I tend to format the sql as follows:
location_names and friends_with are probably returned as arrays of hashes:
Not sure what HTTParty returns, but if it is hashes of arrays of hashes you might try:
To figure out what @checkin_info returns you could try this: