Created
February 20, 2010 03:20
-
-
Save ucnv/309473 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# Usage: ./foursquare-teleportation.rb [vid [shout]] | |
require 'open-uri' | |
require 'net/http' | |
require 'uri' | |
email = '[email protected]' | |
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