Hi,
In one of my PHP scripts, I have been using the CURL library to make a POST call to an external script as per the code below?
On a particular shared URL, CURL is not installed(nor is it an option to be installed at this point in time) - is there an alternative? My brief investigation suggests that 'fopen' might be the way to go (allow_url_fopen is turned on in PHP config).
Can someone provide the equivalent example using 'fopen'? Is there a better alternative?
Thanks,
Adam
PS, here is my CURL code:
$ch = curl_init(); // initialize curl handle
$url = "http://www.mydomain.com/cgi-bin/calc.cgi"; // URL to calc.cgi
curl_setopt($ch, CURLOPT_URL,$url); // set url to post to
curl_setopt($ch, CURLOPT_FAILONERROR, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 10); // times out after 10s
curl_setopt($ch, CURLOPT_POST, 1); // set POST method
curl_setopt($ch, CURLOPT_POSTFIELDS, "amount=$total&ref=xyz"); // fields to POST to calc.cgi
$data = curl_exec($ch); // run the whole process
curl_close($ch);