Ok…. so i’m not a rich guy to afford a iPhone, blackberry or an Android (but i’ts on the wishlist) so i made a little programing… yeah.
Well the ideea is quite simple: get the Google Latitude Latitude and Longitude them send them to 4sqr, after that check for nearby venues…. then check in in the appropriate one:
Let’s begin:
i searched for a phpclass as a base… and found this one witch is a little buggy so i had to do some quick fixes:
now: index.php
include "kernel/foursquare.class.php";
include "kernel/latitude.php";
include "conf/conf.php";
$foursquare = new Foursquare($phone, $pass);
$foursquare->format = "json";
$json = $foursquare->nearbyAndSearch($l, $lo,"30","");
$where = json_decode($json, true);
foreach ($where['groups'] as $element){
foreach ($element['venues'] as $venues){
$nume = $venues['name'];
$id = $venues['id'];
$dist = $venues['distance'];
echo "<a href='check.php?id=$id'>$nume</a> - $dist m<br />" ;
}
}
This thing does the searching for the venues and lists them. then send’s them
check.php – the file
include "kernel/foursquare.class.php"; include "conf/conf.php"; $foursquare = new Foursquare($phone, $pass); $foursquare->format = "json"; $id = $_GET['id']; $check = $foursquare->checkin($id,"","","","1","1","",""); $checkr = json_decode($check, true); echo "<pre>"; var_dump($checkr);
Yeah, the output rocks
so next in line is the how to get the code the Latitude and Longitude from Google Latitude:
function open($url_page)
{
$ch = curl_init($url_page);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_USERAGENT, "Google");
curl_setopt ($ch, CURLOPT_URL, $url_page );
$html = curl_exec ( $ch );
curl_close($ch);
return $html;
}
$xml = open("http://www.google.com/latitude/apps/badge/api?user=-$latidude_code&type=iframe&maptype=roadmap&z=15");
//echo '<pre>';
$datePattern = '^latitude_e6=([0-9]+)^';
preg_match($datePattern, $xml, $matches);
$lat = $matches[1];
$datePattern2 = '^longitude_e6=([0-9]+)^';
preg_match($datePattern2, $xml, $matches2);
$long = $matches2[1];
// the simple way :')
// make the latitude xx.xxxxx
$l .= $lat[0];
$l .= $lat[1];
$l .= ".";
$l .= $lat[2];
$l .= $lat[3];
$l .= $lat[4];
$l .= $lat[5];
$l .= $lat[6];
$l .= $lat[7];
$l .= $lat[8];
// make the longitude yy.yyyyy
$lo .= $long[0];
$lo .= $long[1];
$lo .= ".";
$lo .= $long[2];
$lo .= $long[3];
$lo .= $long[4];
$lo .= $long[5];
$lo .= $long[6];
$lo .= $long[7];
$lo .= $long[8];
and the last
config.php
$phone = ""; // phone # $pass = ""; // password $latidude_code = ""; //get the code from the http://www.google.com/latitude/apps/badge, you need to have it shared on street level, exluclude the - sign
and here is at Google Code
cheers
If this has been useful you should give me a beer


13 responses
Do you want to comment?
Comments RSS and TrackBack Identifier URI ?
Trackbacks