a2bardeals Posted March 12, 2007 Share Posted March 12, 2007 ok so I don't even know how to ask this question but i'll try anyways... Google has a geocoding system now and they have it setup so that you can send an HTTP request to find lat and long of an address. I want to be able to save the outputed info into PHP variables. On the documentation page from google it says this: To access the Maps API geocoder directly using server-side scripting, send a request to http://maps.google.com/maps/geo? with the following parameters in the URI: * q -- The address that you want to geocode. * key -- Your API key. * output -- The format in which the output should be generated. The options are xml, kml, csv, or json. how the #$@! do i send a HTTP request inside a page on my server. I want to quickly find the lat/long of a users address and calculate distance from a store. If i simply type the URL in http://maps.google.com/maps/geo?key=ABCDEFG&q=200+N+MAIN+ST,+NEW+YORK,+NY&output=csv i get a nice little text string with 4 comma seperated values two of which i want to store into variables (lat/long) then pass on to another page which will insert them into the users MySQL row. Seems pretty simple uh? But how do i create the HTTP request inside my document and use the outputed info from google? Quote Link to comment https://forums.phpfreaks.com/topic/42426-http-requests/ Share on other sites More sharing options...
trq Posted March 12, 2007 Share Posted March 12, 2007 curl. Quote Link to comment https://forums.phpfreaks.com/topic/42426-http-requests/#findComment-205800 Share on other sites More sharing options...
a2bardeals Posted March 12, 2007 Author Share Posted March 12, 2007 is cURL the only way? it seems a bit hard to do and I don't know much about compiling PHP or anything related to installing things via command line. Quote Link to comment https://forums.phpfreaks.com/topic/42426-http-requests/#findComment-205803 Share on other sites More sharing options...
trq Posted March 12, 2007 Share Posted March 12, 2007 Curl is included on most hosts. Quote Link to comment https://forums.phpfreaks.com/topic/42426-http-requests/#findComment-205806 Share on other sites More sharing options...
a2bardeals Posted March 12, 2007 Author Share Posted March 12, 2007 i am running my own server with whatever PHP libraries that come with standard Apache how do I know if I have cURL? Quote Link to comment https://forums.phpfreaks.com/topic/42426-http-requests/#findComment-205807 Share on other sites More sharing options...
trq Posted March 12, 2007 Share Posted March 12, 2007 Try running a test script with this in it to see what you have and haven't installed. <?php phpinfo(); ?> ps: PHP does not come with Apache at all. Quote Link to comment https://forums.phpfreaks.com/topic/42426-http-requests/#findComment-205811 Share on other sites More sharing options...
a2bardeals Posted March 12, 2007 Author Share Posted March 12, 2007 my Apache did come with PHP (Mac OS X includes apache as "Web Sharing" as well as PHP) I have PHP Version 4.1.2 but no cURL installed i tried the code: <?php $ch = curl_init("http://www.example.com/"); $fp = fopen("example_homepage.txt", "w"); curl_setopt($ch, CURLOPT_FILE, $fp); curl_setopt($ch, CURLOPT_HEADER, 0); curl_exec($ch); curl_close($ch); fclose($fp); ?> and i get a call to unknown variable curl_init Quote Link to comment https://forums.phpfreaks.com/topic/42426-http-requests/#findComment-205819 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.