Skip to content

Commit

Permalink
README
Browse files Browse the repository at this point in the history
 - actual content
4squatterrc-sample.txt
 - misc. documentation and notes
foursquatter.pl
 - misc cleanup and usage notes
  • Loading branch information
sulrich committed Mar 8, 2010
1 parent 88d7a57 commit a3d9b33
Show file tree
Hide file tree
Showing 3 changed files with 113 additions and 23 deletions.
8 changes: 8 additions & 0 deletions 4squatterrc-sample.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# since this stores your foursquare password in clear text, make sure that you
# put the appropriate permissions in place.
# foursquare account username - can also be the registered phone #
esquare_user = "[email protected]"
# foursquare account password
esquare_pass = "secretpassword"
esquare_host = "api.foursquare.com:80"
# the user-agent
esquare_agent = "foursquatter 0.01"
# if you're going to use the batch check-in functionality this is where we
# would store the file containing the list of venues you'd like to update en
# masse
esquare_vfile = "/path_to_home/squatter-venues.txt"
75 changes: 75 additions & 0 deletions README
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
* overview

warning - this is an anti-social script. i'm not recommending its use, but i
can see the utility. if you must have the mayorship of your local
bar/coffeeshop, etc. you might find it useful. this exercises a very little
bit of the foursquare API and allows you to interact with the API.

* requirements

- libwww-perl - this has the HTTP client functionality, commonly available.
- JSON - used to parse the responses from foursquare

* configuration

you'll want to make sure that you create the appropriate .4squatterrc file
with the right username and password, etc. put into place.

* seeding the process

in order to seed the process you should dig up the latitude and longitude of
the area where you'd like to poke around. then get the list of the venues
that are nearby.


ZenDoggy[sulrich]% foursquatter.pl --action=disp_venues --geolat=44.9116 \
--geolong=-93.329

# vid venue name geolat geolong
#---------------------------------------------------------------------
19098 Edina Grill 44.9116 -93.329
993195 Bone Adventure 44.9116893 -93.3290071
477665 Normandale College 44.9117382 -93.3290307
358183 il vostro boutique 44.9118158 -93.3290075
31532 Salut Bar Americain - Edina 44.9115 -93.3294
1450348 Julia Bretey Salon 44.9119001 -93.3290077
691615 Gyropolis 44.9114999 -93.3294
1025052 James Loren Salon 44.9118 -93.3294
493299 New China Wok 44.9120019 -93.329008
52142 Premier Cheese Market 44.912 -93.329

redirect the output to the file that you'd like to use to be the see for batch updates.


ZenDoggy[sulrich]% foursquatter.pl --action=disp_venues --geolat=44.9116 \
--geolong=-93.329 --vcount=30 > foo-venues.txt

edit this file to add/remove the venues that you have in the mix. note that
the fields are tab delimited. make sure you don't rip out the tabs when you
save the file.

batch file format:
vid <tab> name <tab> <geolat> <tab> <geolong> <newline>

lines starting with a hash are ignored as comments.




* single shot check-in

for this, all you need to provide is the

ZenDoggy[sulrich]% foursquatter.pl --action=checkin --vid=31532
checkin success: 31532 - <note this will be blank in the single shot mode>

* batch check-in

ZenDoggy[sulrich]% foursquatter.pl --action=checkin-batch
checkin success: 19098 - Edina Grill

... elided for brevity ...

checkin success: 227616 - Starbucks
checkin success: 701995 - Bella Salon and Spa

53 changes: 30 additions & 23 deletions foursquatter.pl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/opt/local/bin/perl -w
#!/usr/bin/env perl

use LWP::UserAgent;
use HTTP::Request::Common;
Expand Down Expand Up @@ -26,34 +26,14 @@

my $debug = 0;

# valid actions
#
# checkin-single [--vid]
# checkin-batch [--file=filename]
# disp_venues --geolat=s --geolong=s [--vcount=#]
#
#
# misc. notes
#
# to get a comprehensive list of venues near the specified coordinates
#
# http://api.foursquare.com/v1/venues?geolat=44.914128&geolong=-93.329555&l=50
#
# checking in:
#
# % curl -d "vid=19098&geolat=44.9116&geolong=-93.329" -u \
# "username:password" "http://api.foursquare.com/v1/checkin"
#
#

# parse the options and determine the action that we're going to take
if ( $opts{action} eq '' ) {
&printUsage("no action specified");
exit;
} else { $opts{'action'} =~ tr/A-Z/a-z/; }


# parse the various CLI opts to make sure we have what we need
# parse the various CLI opts
if ($opts{action} eq "disp_venues") {
if ($opts{geolat} eq "" || $opts{geolong} eq "" ) {
&printUsage("missing coordinates (geolat or geolong)");
Expand Down Expand Up @@ -200,12 +180,38 @@ ()
print STDERR $message . "\n";

print STDERR <<EOF;
usage: edina-square.pl
usage: foursquatter.pl
you need to set some options and variables. check the code to see what you
need to setup here.
foursquare.pl --action=<action>
valid actions:
checkin
--vid=
example:
foursquatter.pl --action=checkin --vid=XXXX
checkin-batch
[--file=filename]
example:
foursquatter.pl --action=checkin-batch
disp_venues
--geolat=s --geolong=s [--vcount=#]
example:
foursquatter.pl --action=disp_venues --geolat=xx.xxx --geolong=yy.yyy \
--vcount=NN
EOF

return;
}

Expand All @@ -216,6 +222,7 @@ ()
my %config = ();
open(INFILE, $file) || die "error opening: $file";
while (<INFILE>) {
next if /^#/; # skip comments
my ($key, $value) = /(.*)\s+\=\s+[\"|\'](.*)[\"|\']/;
$key =~ s/ //; # rip out any white space from the key
$config{$key} = $value;
Expand Down

0 comments on commit a3d9b33

Please sign in to comment.