help with curl
| From: | Angelo Zanetti | Date: | Sun, 24 Dec 2006 14:49:08 +0000 |
| Subject: | help with curl | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-246191@lists.php.net to get a copy of this message | ||
Dear All,
I have a script that uses curl to execute an http request now I use the same code for two different servers. And it works on the first server but not the second. I have stored the URL that it generates on the server that doesnt work and if I paste it into the address bar of the browser it works but somehow the script doesnt execute it.
$ch = curl_init(); // initialize curl handle
curl_setopt($ch, CURLOPT_URL,$url); // set url to post to
curl_setopt($ch, CURLOPT_FAILONERROR, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);// allow redirects
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); // return into a variable
curl_setopt($ch, CURLOPT_TIMEOUT, 8); // times out after 4s
curl_setopt($ch, CURLOPT_GET, 1); // set POST method
curl_setopt($ch, CURLOPT_POSTFIELDS, $dat); // add POST
curl_setopt($ch, CURLOPT_PORT, $port); // set POST method
$result = curl_exec($ch); // run the whole process
now is there anything that can be causing this not to execute? I have increasd the timeout to 8 seconds (is this enough). COuld there be a problem with the server not being able to execute a URL in that way?
Is there anything else I can do to trouble shoot this? IF the URL is as follows: http://www.sdfsfjs.com?username=hello&password=goodbye do I need to set the GET variable string seperately in the CURLOPT_POSTFIELDS or can I just send it as one string?
Thanks in advance.
regards
--
------------------------------------------------------------------------
Angelo Zanetti
Systems developer
------------------------------------------------------------------------
*Telephone:* +27 (021) 469 1052
*Mobile:* +27 (0) 72 441 3355
*Fax:* +27 (0) 86 681 5885
*
Web:* http://www.zlogic.co.za
*E-Mail:* angelo@zlogic.co.za <mailto:angelo@zlogic.co.za>