<?php
$url = 'http://wherein.yahooapis.com/v1/document';
$appid = 'Gux4Z8LIkY1IKfVXnRcMegs3IjNfmUhl';
$type = 'documentType=text/plain';
$q = <<<EOB
I was born in Greenland, grew up in Denmark and have also lived
in Canada, and Brazil and now live in Sunnyvale. Today I am
in Tapachula giving a talk. I fly back to San Francisco tomorrow
and next week I am going to Rio de Janeiro.
Jack London is not here.
EOB;
$post="appid=$appid&$type&documentContent=".rawurlencode($q);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
$data = curl_exec($ch);
curl_close($ch);
$x = simplexml_load_string($data);
foreach($x->document->placeDetails as $p) {
$woeid =$p->place->woeId;
$type = $p->place->type;
$name = $p->place->name;
$lat = $p->place->centroid->latitude;
$lon = $p->place->centroid->longitude;
echo "$woeid $type: $name at $lat,$lon<br>\n";
}
?>