Skip to content

Instantly share code, notes, and snippets.

@bkenny
Created July 9, 2012 11:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bkenny/3076004 to your computer and use it in GitHub Desktop.
Save bkenny/3076004 to your computer and use it in GitHub Desktop.
Foursquare API
require 'json'
require 'httparty'
require 'geocoder'
require 'foursquare2'
require 'hashie'
@@client = Foursquare2::Client.new(:client_id => 'PQPTTYWDIXOYHUYJMO0UX30W1VI0Q3IHXC314QSA50VMZDNB', :client_secret => 'AIUV3COEJRQOMDUQXEFXN0X5LPRSEP1P43TLNMN00RQ30U4H')
def show_subcategories
@venues = @@client.venue_categories
@venues.each do |venue|
@subcategories = venue["categories"]
@subcategories.each do |subcategory|
puts subcategory["name"]
puts subcategory["id"]
end
end
end
def search_by_category(categoryId, ll)
@search = Hashie::Mash.new(@@client.search_venues(:ll => ll, :intent => "browse", :radius => 500, :categoryId => categoryId))
@search.groups.first.items.each do |venue|
puts venue.name
end
end
@location = "Dublin City"
@locationgeo = Geocoder.search(@location)
coords = @locationgeo.first.latitude.to_s + ', ' + @locationgeo.first.longitude.to_s
show_subcategories
search_by_category("4bf58dd8d48988d1d2941735", coords)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment