Skip to content

Instantly share code, notes, and snippets.

@benbalter
Created December 27, 2012 04:12
Show Gist options
  • Save benbalter/4385445 to your computer and use it in GitHub Desktop.
Save benbalter/4385445 to your computer and use it in GitHub Desktop.
Auto like a given user's foursquare checkins
require 'foursquare2'
access_token = ''
target_user_id = ''
#URL to request access token
#https://foursquare.com/oauth2/authenticate?client_id=XXX&response_type=token&redirect_uri=http://local.dev
client = Foursquare2::Client.new( :oauth_token => access_token, :api_version => '20120505' )
client.recent_checkins( :limit => 100 ).each do |checkin|
next unless checkin.user.id == target_user_id
#library does not support likes, send request directly
response = client.connection.post do |req|
req.url "checkins/#{checkin.id}/like", {}
end
#trigger error if need be
response = client.return_error_or_body(response, response.body.response)
puts "Boom. Liked #{checkin.user.firstName} #{checkin.user.lastName}'s checkin to #{checkin.venue.name}. Liked by #{response.likes.summary}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment