Skip to content

Instantly share code, notes, and snippets.

@ehlyzov
Created July 10, 2014 12:38
Show Gist options
  • Save ehlyzov/3d5b7ad6a34e22e19a52 to your computer and use it in GitHub Desktop.
Save ehlyzov/3d5b7ad6a34e22e19a52 to your computer and use it in GitHub Desktop.
working with 4sq
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