Reputation: 25755
i am kind of new to API thing, and i need help understanding on what exactly is happening with the below Code.
$address = 'Bhatkal, Karnataka, India';
$requestUrl = 'http://maps.google.com/maps/geo?output=xml&key=aabbcc&oe=utf-8&q='.urlencode($address);
$xml = simplexml_load_file($requestUrl);
i understand that HTTP is capable of sending Request and getting response in return isn't it? what i am unable to understand is the third and last function that is $xml = simplexml_load_file($requestUrl);
when i do a print_r($xml)
i get an object in return which prints all the object details i got back as response,
and where do i look up for Google Maps API URL?
Upvotes: 0
Views: 904
Reputation: 4916
That function does not process the request (nor the URL), only the response, Google processes the URL that, the function just "visit's" it. You can do as well: here. The XML file you see here is ending up in the variable $xml, parsed.
EDIT: the URL in this post is not working too well, because of the key parameter
Upvotes: 1
Reputation: 8856
The response object will help you to extract the data from the response. Check out the details of Google Maps API
Upvotes: 1
Reputation: 12508
simplexml_load_file internally uses the fopen wrapper and opens the remote xml that would be produced by the url and then converts into an array for php to easily use.
Upvotes: 1