Hardware Reference
In-Depth Information
Now that you've got the location,
it's time to find out who you're
sending the results to, and format
your response appropriately. The
information you want is in the HTTP
user agent.
8
Continued from previous page.
// close the connection:
fclose($filePath);
// decide on the output based on the client type:
switch ($userAgent) {
case "arduino":
// Arduino wants a nice short answer:
echo "<$lat,$long,$country>\n";
break;
case "processing":
// Processing does well with lines:
echo "Latitude:$lat\nLongitude:$long\nCountry:$country\n\n";
break;
default:
// other clients can take a long answer:
echo <<<END
<html>
<head></head>
<body>
<h2>Where You Are:</h2>
Your country: $country<br>
Your IP: $ipAddress<br>
Latitude: $lat<br>
Longitude: $long<br>
</body>
</html>
END;
}
?>
 
Search WWH ::




Custom Search