Jump to content

http requests


a2bardeals

Recommended Posts

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?

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.