Page 1 of 1

requesting url parameters from a website

Posted: Thu Oct 27, 2005 3:09 pm
by FREESTYLER
Hey guys once again im stuck
heres my problem:
i need to send a suburb, address, state, postcode to the url http://www.multimap.com.au/map/places.cgi
this in turn returns a latitude and a longitude
i then need to store these in my php page

i found this code, but dont think its helping.

Code: Select all

$url="http://anything";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_POST, 1);
curl_setopt ($ch, CURLOPT_POSTFIELDS, "fieldname=fieldvalue&fieldname=fieldvalue&");
#curl_setopt ($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
$store = curl_exec ($ch);
$content = curl_exec ($ch); # This returns HTML
curl_close ($ch);
TO GET A PAGE USING A URL ONLY:

Code: Select all

$url="http://anything";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
$store = curl_exec ($ch);
$xml = curl_exec ($ch);
curl_close ($ch);
any ideas?
i have this code in java, but its a bit complex to trasnlate into php i think

Posted: Thu Oct 27, 2005 3:13 pm
by feyd
calling curl_exec() with the same curl handle twice simply repeats the operation.. I don't see a need to do so..

The first one is the way to go if the cgi file must be posted to.. otherwise the second will work fine, along with using file_get_contents() if your server allows urls via fopen() based functions..

Posted: Thu Oct 27, 2005 3:25 pm
by FREESTYLER
ok i dont understand that?
ive read the php doc's on file_get_contents()
seems to want to open a file though?
im new to php sorry

Posted: Thu Oct 27, 2005 3:29 pm
by feyd

Code: Select all

$content = file_get_contents('http://google.com');
the proceeding code will fetch what google returns from that particular url. It'll be the raw HTML or rather HTTP response, no headers or special information, just the page content. (That is, if your server has allow_url_fopen on)

Posted: Fri Oct 28, 2005 5:37 pm
by FREESTYLER
ok, ive kinda got it working now
but it returns the html code/ the webpage
i just want to extract to values from the page?

Posted: Fri Oct 28, 2005 7:03 pm
by feyd
what values? your code above simply requests the page response..