Created
July 10, 2009 22:04
-
-
Save sh1mmer/144854 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
$input = "some text"; | |
$query = "select centroid.latitude, centroid.longitude from geo.places where text='$input'"; | |
$url = "http://query.yahooapis.com/v1/public/yql?q=" . urlencode($query) . "&format=json&callback="; | |
$ch = curl_init($url); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | |
$response = curl_exec($ch); | |
$results = json_decode($response, true); | |
$results = $results["query"]["results"]; | |
if (count($results["place"]) == 1) { | |
$lat = $results["place"]["centroid"]["latitude"]; | |
$long = $results["place"]["centroid"]["longitude"]; | |
} else { | |
$lat = $results["place"][0]["centroid"]["latitude"]; | |
$long = $results["place"][0]["centroid"]["longitude"]; | |
} | |
if (!(lat & long)) { | |
//put code in here for when there isn't a match. | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment