note 11439 added to curl_setopt

From: Date: Wed, 21 Feb 2001 07:22:54 +0000
Subject: note 11439 added to curl_setopt
Groups: php.notes 
Request: Send a blank email to php-notes+get-11341@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). http://www.php.net/manual/en/function.curl-setopt.php

« previous php.notes (#11341) next »