问题
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¢er=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