Created
July 10, 2014 12:38
-
-
Save ehlyzov/3d5b7ad6a34e22e19a52 to your computer and use it in GitHub Desktop.
working with 4sq
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'json' | |
require 'net/http' | |
require 'csv' | |
uri = URI('https://api.foursquare.com/v2/venues/categories?oauth_token=QRY3YNHKTYK24JSQPFVBII2YI233T5OZHO2ZQMCG3YU2U05P&v=20140708&locale=ru') | |
PUSH = -> (categories, scope) do | |
categories.inject([]) do |res, category| | |
row = scope + [category['id'], category['name']] | |
res + [row, *PUSH[category['categories'] || [], row]] | |
end | |
end | |
PUSH[JSON.parse(Net::HTTP.get(uri))['response']['categories'], []] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment