Skip to content

Instantly share code, notes, and snippets.

@ucnv
Created February 20, 2010 03:20
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 ucnv/309473 to your computer and use it in GitHub Desktop.
Save ucnv/309473 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
# Usage: ./foursquare-teleportation.rb [vid [shout]]
require 'open-uri'
require 'net/http'
require 'uri'
email = 'your@mail.address'
password = 'your-password'
vid, shout =
if ARGV.size == 0
[rand(1300000), nil]
else
ARGV
end
html = open("http://foursquare.com/venue/#{vid}").read
lat, long =
if(html.match(%r{point = new GLatLng\(([0-9.-]+), ([0-9.-]+)\);}))
[$1, $2]
else
puts "Wrong location."; exit
end
data = "vid=#{vid}&private=0&twitter=1&facebook=0&geolat=#{lat}&geolong=#{long}&geohacc=10.000000"
data += "&shout=#{URI.escape(shout)}" unless(shout.nil?)
req = Net::HTTP::Post.new('/v1/checkin.json')
req['User-Agent'] = 'iPhone internal:1.5.1 20100119'
req['Content-Type'] = 'application/x-www-form-urlencoded'
req.basic_auth(email, password)
Net::HTTP.start('api.foursquare.com', 80) do |http|
res = http.request(req, data)
puts res.body
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment