Facebook Graph API and koala: How to find places in a city

旧巷老猫 提交于 2019-12-25 04:42:17

问题


Using a Rails app with koala, how can I get a list of restaurants and places within a city?

For reference:

graph = Koala::Facebook::API.new(@current_user.oauth_token)
graph.get_object("me")["location"]["name"]

gets me the user's city.


回答1:


To use Graph API Search with Koala Gem create an object and use .graph-call method and pass in the api call you would make as a single string parameter like so:

fb = Koala::Facebook::API.new(ENV['FACEBOOK_CLIENT_TOKEN'])
lookup = fb.graph_call("search?q=coffee&type=place&center=37.76,-122.427&distance=1000")



回答2:


I don't know the specifics of the Koala framework, but Graph API-wise you can use the search endpoint es described at https://developers.facebook.com/docs/graph-api/using-graph-api/v2.2#search

Sample query:

GET graph.facebook.com/search?
    q=coffee&
    type=place&
    center=37.76,-122.427&
    distance=1000

Also have a look at

  • http://www.rubydoc.info/github/arsduo/koala/Koala/Facebook/GraphAPIMethods:search


来源:https://stackoverflow.com/questions/27679956/facebook-graph-api-and-koala-how-to-find-places-in-a-city

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!