Need help understanding Google Maps API URL?
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 unde开发者_开发问答rstand 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,
- how does the function process the URL?
- does it use CURL (i have very less idea about what is CURL).
and where do i look up for Google Maps API URL?
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
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.
The response object will help you to extract the data from the response. Check out the details of Google Maps API
精彩评论