Example #1
0
        die("Error: No password specified.\n");
    }
    return array($username, $password);
}
if (!file_exists($mobileMePasswordFile)) {
    echo "You will need to type your MobileMe username/password. They will be\n";
    echo "saved in {$mobileMePasswordFile} so you don't have to type them again.\n";
    echo "If you're not cool with this, you probably want to delete that file\n";
    echo "at some point (they are stored in plaintext).\n\n";
    echo "You do need a working MobileMe account for playnice to work, and you\n";
    echo "need to have enabled the Find My iPhone feature on your phone.\n\n";
    list($mobileMeUsername, $mobileMePassword) = promptForLogin("MobileMe");
    $f = fopen($mobileMePasswordFile, "w");
    fwrite($f, "<?php\n\$mobileMeUsername=\"{$mobileMeUsername}\";\n\$mobileMePassword=\"{$mobileMePassword}\";\n?>\n");
    fclose($f);
    chmod($mobileMePasswordFile, 0600);
    echo "\n";
} else {
    @(include $mobileMePasswordFile);
}
// Get the iPhone location from MobileMe
echo "Fetching iPhone location...";
$mobileMe = new Sosumi($mobileMeUsername, $mobileMePassword);
$iphoneLocation = $mobileMe->locate();
echo "got it.\n";
echo "iPhone location: {$iphoneLocation->latitude}, {$iphoneLocation->longitude} (accuracy: {$iphoneLocation->accuracy} meters)\n";
// Now update Brightkite
echo "Updating Brightkite...";
$bk->updateBrightkite($iphoneLocation->latitude, $iphoneLocation->longitude, $iphoneLocation->accuracy);
// All done.
echo "Done!\n";
Example #2
0
    echo "\n";
} else {
    @(include $mobileMePasswordFile);
}
if (!$google->haveCookie()) {
    echo "No Google cookie found. You will need to authenticate with your\n";
    echo "Google username/password. You should only need to do this once;\n";
    echo "we will save the session cookie for the future.\n\n";
    list($username, $password) = promptForLogin("Google");
    echo "Acquiring Google session cookie...";
    $google->login($username, $password);
    echo "got it.\n";
}
// Get the iPhone location from MobileMe
echo "Fetching iPhone information...";
$mobileMe = new Sosumi($mobileMeUsername, $mobileMePassword);
if (!$mobileMe->authenticated) {
    echo "Unable to authenticate to MobileMe. Is your password correct?\n";
    exit;
}
if (count($mobileMe->devices) == 0) {
    echo "No iPhones found in your MobileMe account.\n";
    exit;
}
echo "found " . count($mobileMe->devices) . " device(s):\n";
reset($mobileMe->devices);
foreach ($mobileMe->devices as $device) {
    echo "Device ID: " . $device['deviceId'] . "\n";
}
echo "Determining iPhone location...";
$iphoneLocation = $mobileMe->locate($mobileMe->devices[$deviceId]);
Example #3
0
<?php

require 'class.sosumi.php';
// You'll need to enter your own Google Maps API key
// Get one from here: http://code.google.com/apis/maps/signup.html
$google_maps_key = 'ABQIAAAAXANstaeNAI9u7tH717M2lhQcvfltqJ-4mcX1kaBXHuD0hiFsYRQnW86DzGiVzuP_rYJp7TqRzxNk6A';
// Enter your MobileMe username and password
$ssm = new Sosumi('*****@*****.**', '%nichimGrifF13');
$loc = $ssm->locate();
if (isset($_POST['btnSend'])) {
    $alarm = isset($_POST['alarm']);
    $ssm->sendMessage($_POST['msg'], $alarm);
    header('Location: ' . $_SERVER['PHP_SELF']);
}
?>
<!DOCTYPE html "-//W3C//DTD XHTML 1.0 Strict//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
    <title>Sosumi</title>
    <link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/2.8.0r4/build/reset-fonts-grids/reset-fonts-grids.css">
    <link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/2.8.0r4/build/base/base-min.css">
    <style type="text/css" media="screen">
        p { text-align:left; }
        #map_canvas { width:640px; height:480px; border:1px solid #000; }
    </style>
    <script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=<?php 
echo $google_maps_key;
?>
&amp;sensor=false" type="text/javascript"></script>
Example #4
0
#!/usr/bin/php
<?php 
// This is a simple cron script you can use to track
// your location over time. It uses the MySQL schema
// pasted below.
// CREATE TABLE `history` (
//   `dt` datetime NOT NULL,
//   `lat` decimal(10,6) NOT NULL,
//   `lng` decimal(10,6) NOT NULL,
//   UNIQUE KEY `dt` (`dt`)
// )
require 'class.sosumi.php';
$ssm = new Sosumi('your_username', 'your_password');
$loc = $ssm->locate();
if (strlen($loc->latitude)) {
    $db = mysql_connect('localhost', 'root', '');
    mysql_select_db('sosumi', $db) or die(mysql_error());
    $dt = date('Y-m-d H:i:s', strtotime($loc->date . ' ' . $loc->time));
    $lat = mysql_real_escape_string($loc->latitude, $db);
    $lng = mysql_real_escape_string($loc->longitude, $db);
    $query = "INSERT INTO history (`dt`, `lat`, `lng`) VALUES ('{$dt}', '{$lat}', '{$lng}')";
    mysql_query($query, $db) or die(mysql_error());
}