note 11439 modified in function.curl-setopt by irc-html
| From: | irc-html@php.net | Date: | Sat, 19 Jan 2002 22:42:08 +0000 |
| Subject: | note 11439 modified in function.curl-setopt by irc-html | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-25523@lists.php.net to get a copy of this message | ||
The TIMEOUT function seems to take an extra second before timing out (ex. you specify 4s, it will
timeout a little after 5s).
Some useful test code to learn how to use cURL:
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"http://www.yoursite.com/test.php");
curl_setopt($ch, CURLOPT_FAILONERROR, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 3); //times out after 4s
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "v1=10&v2=20&v3=30");
$result=curl_exec ($ch);
curl_close ($ch);
echo "result='$result'<br>";
-------------------------------
test.php on www.yoursite.com:
<?
echo "v1='$v1', v2='$v2', v3='$v3'
==".($v1+$v2+$v3)."<br>";
?>
Thus we've posted a form to this remote site and received in return it's output
(v1='10', v2='20', v3='30' ==60).
--was--
The TIMEOUT function seems to take an extra second before timing out (ex. you specify 4s, it will
timeout a little after 5s).
Some useful test code to learn how to use cURL:
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"http://www.yoursite.com/test.php");
curl_setopt($ch, CURLOPT_FAILONERROR, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 3); //times out after 4s
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "v1=10&v2=20&v3=30");
$result=curl_exec ($ch);
curl_close ($ch);
echo "result='$result'<br>";
-------------------------------
test.php on www.yoursite.com:
<?
echo "v1='$v1', v2='$v2', v3='$v3'
==".($v1+$v2+$v3)."<br>";
?>
Thus we've posted a form to this remote site and received in return it's output
(v1='10', v2='20', v3='30' ==60).
http://www.php.net/manual/en/function.curl-setopt.php