Class: Foursquare
Defined Under Namespace
Classes: AuthenticationRequiredError, VenueNotFoundError
Class Method Summary collapse
-
.available? ⇒ Boolean
Test if API is up and available api.playfoursquare.com/v1/test.
-
.cities ⇒ Object
Returns a list of currently active cities.
-
.tips(options = {}) ⇒ Object
Returns a list of tips near the area specified.
-
.venues(options = {}) ⇒ Object
Returns a list of venues near the area specified or that match the search term.
Instance Method Summary collapse
-
#checkin(options = {}) ⇒ Object
:geolat => (optional, but recommended) :geolong => (optional, but recommended).
-
#initialize(username = nil, password = nil) ⇒ Foursquare
constructor
A new instance of Foursquare.
-
#user(options = {}) ⇒ Object
Returns data for a particular user.
-
#venues(options = {}) ⇒ Object
Like self.venues(), except when authenticated the method will return venue meta-data related to you and your friends.
Constructor Details
#initialize(username = nil, password = nil) ⇒ Foursquare
Returns a new instance of Foursquare.
11 12 13 |
# File 'lib/foursquare.rb', line 11 def initialize(username = nil, password = nil) @auth = {:username => username, :password => password} end |
Class Method Details
.available? ⇒ Boolean
Test if API is up and available api.playfoursquare.com/v1/test
114 115 116 117 |
# File 'lib/foursquare.rb', line 114 def self.available? response = get("/test.json", :query => nil) (!response.nil? && response["response"] == "ok") ? true : false end |
.cities ⇒ Object
Returns a list of currently active cities. api.playfoursquare.com/v1/cities
78 79 80 |
# File 'lib/foursquare.rb', line 78 def self.cities get("/cities.json", :query => nil)["cities"] end |
.tips(options = {}) ⇒ Object
Returns a list of tips near the area specified. (The distance returned is in miles). Options
:geolat => latitude (required)
:geolong => longitude (required)
89 90 91 92 |
# File 'lib/foursquare.rb', line 89 def self.tips( = {}) require_latitude_and_longitude() # XXX end |
.venues(options = {}) ⇒ Object
Returns a list of venues near the area specified or that match the search term. Distance returned is in miles. It will return venue meta-data related to you and your friends.
Options
:geolat => latitude (required)
:geolong => longitude (required)
:r => radius in miles (optional)
:l => limit of results (optional, default 10)
:q => keyword search (optional)
106 107 108 109 110 |
# File 'lib/foursquare.rb', line 106 def self.venues( = {}) require_latitude_and_longitude() get("/venues.json", :query => )["venues"]["group"] end |
Instance Method Details
#checkin(options = {}) ⇒ Object
:geolat => (optional, but recommended)
:geolong => (optional, but recommended)
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/foursquare.rb', line 31 def checkin( = {}) unless [:private].nil? [:private] = 1 if [:private] == true [:private] = 0 if [:private] == false end unless [:twitter].nil? [:twitter] = 1 if [:twitter] == true [:twitter] = 0 if [:twitter] == false end response = self.class.post("/checkin.json", :query => , :basic_auth => @auth) raise VenueNotFoundError if response.keys.include?("addvenueprompt") response["checkin"] end |
#user(options = {}) ⇒ Object
Returns data for a particular user
Options
:uid => userid for the user whose information you want to retrieve.
if you do not specify a 'uid', the authenticated user's
profile data will be returned.
:badges => (optional, default: false) set to true ("1") to also show
badges for this user
:mayor => (optional, default: false) set to true ("1") to also show
venues for which this user is a mayor
68 69 70 |
# File 'lib/foursquare.rb', line 68 def user( = {}) self.class.get("/user.json", :query => )["user"] end |
#venues(options = {}) ⇒ Object
Like self.venues(), except when authenticated the method will return venue meta-data related to you and your friends.
49 50 51 52 53 54 55 56 |
# File 'lib/foursquare.rb', line 49 def venues( = {}) self.class.require_latitude_and_longitude() response = self.class.get("/venues.json", :query => , :basic_auth => @auth)["venues"] response && response.flatten end |