Re: [PHP] Calculating driving distance between UK postcodes
On Fri, May 4, 2012 at 9:18 AM, Terry Ally (Gmail) wrote: > Google works in Javascript extensively - not a language with which I > have in-depth experience hence my reason for asking for PHP solution. > > For example the following will get me a JSON output with the distance in > Kms and time. I don't know how to get PHP to read this information and > extract just the distance. I need the distance so that I can calculate cost > of a trip. > > http://maps.googleapis.com/maps/api/distancematrix/json"; method="get"> > > > > > onClick="document.getElementById('google').submit()">Get > Distance > Using Google Maps API is pretty straight-forward. You don't need to set up a form or a use a POST to get the info. This page should describes how to use a standard GET query to get the info you want: < https://developers.google.com/maps/documentation/distancematrix/ > Setting up the proper URL to call, you can activate it using file_get_contents provided you have allow_url_fopen set to true in php.ini. (Do make sure to check for possible errors returned.) You can get the response back as either JSON or XML, both of which PHP can parse into useful data structures: < http://us.php.net/manual/en/function.json-decode.php > < http://us.php.net/manual/en/book.simplexml.php > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Calculating driving distance between UK postcodes
On Friday, May 4, 2012 at 10:18, Terry Ally (Gmail) wrote: > Google works in Javascript extensively - not a language with which I > have in-depth experience hence my reason for asking for PHP solution. > > For example the following will get me a JSON output with the distance in > Kms and time. I don't know how to get PHP to read this information and > extract just the distance. I need the distance so that I can calculate cost > of a trip. > > http://maps.googleapis.com/maps/api/distancematrix/json"; method="get"> > > > > > onClick="document.getElementById('google').submit()">Get > Distance > > > > > > > On 4 May 2012 15:08, David OBrien wrote: > > > Google is still your friend > > > > On Fri, May 4, 2012 at 9:36 AM, Terry Ally (Gmail) > > wrote: > > > > > Does anyone have a working/example PHP script that calculates driving > > > distances between UK postcodes that they can share? > > > > > > Thanks > > > > > > -- > > > *Terry Ally* > > > > > > Twitter.com/terryally > > > Facebook.com/terryally > > > ~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~ > > > To print or not to print this email is the environmentally-searching > > > question! > > > Which has the highest ecological cost? A sheet of paper or constantly > > > switching on your computer and connecting to the Internet to read your > > > email? > > > > > > > > > > > http://stackoverflow.com/questions/2296087/using-php-and-google-maps-api-to-work-out-distance-between-2-post-codes-uk > > > > > -- > *Terry Ally* > Twitter.com/terryally > Facebook.com/terryally > ~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~ > To print or not to print this email is the environmentally-searching > question! > Which has the highest ecological cost? A sheet of paper or constantly > switching on your computer and connecting to the Internet to read your > email? > > You should look into curl. Make a post request with the form data as post payload. -- Mike Mackintosh www.HighOnPHP.com
Re: [PHP] Calculating driving distance between UK postcodes
Google works in Javascript extensively - not a language with which I have in-depth experience hence my reason for asking for PHP solution. For example the following will get me a JSON output with the distance in Kms and time. I don't know how to get PHP to read this information and extract just the distance. I need the distance so that I can calculate cost of a trip. http://maps.googleapis.com/maps/api/distancematrix/json"; method="get"> Get Distance On 4 May 2012 15:08, David OBrien wrote: > Google is still your friend > > On Fri, May 4, 2012 at 9:36 AM, Terry Ally (Gmail) wrote: > >> Does anyone have a working/example PHP script that calculates driving >> distances between UK postcodes that they can share? >> >> Thanks >> >> -- >> *Terry Ally* >> >> Twitter.com/terryally >> Facebook.com/terryally >> ~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~ >> To print or not to print this email is the environmentally-searching >> question! >> Which has the highest ecological cost? A sheet of paper or constantly >> switching on your computer and connecting to the Internet to read your >> email? >> > > > http://stackoverflow.com/questions/2296087/using-php-and-google-maps-api-to-work-out-distance-between-2-post-codes-uk -- *Terry Ally* Twitter.com/terryally Facebook.com/terryally ~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~ To print or not to print this email is the environmentally-searching question! Which has the highest ecological cost? A sheet of paper or constantly switching on your computer and connecting to the Internet to read your email?
Re: [PHP] Calculating driving distance between UK postcodes
Google is still your friend On Fri, May 4, 2012 at 9:36 AM, Terry Ally (Gmail) wrote: > Does anyone have a working/example PHP script that calculates driving > distances between UK postcodes that they can share? > > Thanks > > -- > *Terry Ally* > Twitter.com/terryally > Facebook.com/terryally > ~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~ > To print or not to print this email is the environmentally-searching > question! > Which has the highest ecological cost? A sheet of paper or constantly > switching on your computer and connecting to the Internet to read your > email? > http://stackoverflow.com/questions/2296087/using-php-and-google-maps-api-to-work-out-distance-between-2-post-codes-uk