|
Posted by Erwin Moller on 12/01/06 16:18
devranger wrote:
> I have used curl_setopt($ch, CURLOPT_POST, true); and curl_setopt($ch,
> CURLOPT_POSTFIELDS, $data); on post forms to retrun results, but what
> about a GET Form Method? How do you deal with these with curl? The
> same commands?
>
> The particular instance I am dealing with is a store locator and it is
> not as easy as just calling the url with the variables becasue it runs
> some script behind the scene that does a bunch of calculations for
> calculating the lat. and lon. of the store so it can call a mappoint
> map. After the form submission the url is a mess and pretty customized
> to the zip code searched with lat and lon.
>
> Here is an example of the form action:
> <form Method="GET"
>
Action="http://go.mappoint.net/ccc/Geocode.aspx?brand=h&FC=ccc&FC=ccc"
> Name="OutsideUS">
>
> Here is an mocked up example of a resulting URL after the form
> submission:
>
>
http://go.mappoint.net/ccc/PrxResults.aspx?&LOC=33.8982869073812%3a-117.612688299845&CT=33.8982869073812%3a-117.612688299845%3a14.2501126753095%3a10.6875845064821&DSN=MapPoint.NA&GAD2=&GCITY=&GSTATE=&GZIP=92880&GAD3=+92880&GAD4=USA&IC=33.8982869073812%3a-117.612688299845%3a33%3a+92880&LL=en-US&AD4=USA&FC=isccc&brand=a
>
> How would I deal with this in curl? Your help is much appreciated.
>
> Thank you!
Hi,
I think just assembling the URL should do the trick.
So just add all name/value pairs you have to the url.
eg:
$baseURL = "http://go.mappoint.net?";
// assuming you have your info in an assoc-array:
$myNameValues = array(
"LOC" => "23.327467234",
"CT" => "34.879327689"
);
// urlencode all values
$urlEncodedParts = array();
foreach ($myNameValues as $key => $value){
$urlEncodedParts = $key."=".urlencode($value);
}
// add to baseurl
$baseURL .= implode("&",$urlEncodedParts );
Then just use the baseurl in CURL without POST-options.
(Not tested)
Regards,
Erwin Moller
[Back to original message]
|