note 59481 added to ref.curl

From: Date: Thu, 08 Dec 2005 05:08:20 +0000
Subject: note 59481 added to ref.curl
Groups: php.notes 
Request: Send a blank email to php-notes+get-99727@lists.php.net to get a copy of this message
Hello everybody, The solution how to use proxy in correct way with curl was founded. Here is the part of code which was successfully used for checking proxy server and can be used by anybody as an example. During the research one very useful parameter of curl was discovered: CURLOPT_TIMEOUT. If script is using curl object with proxy parameter it is very important to set this parameter. There is possibility that proxy will not replay (die or big latency) until PHP script’s timeout exceed. $cUrl = curl_init(); curl_setopt($cUrl, CURLOPT_URL, $requestUrl); curl_setopt($cUrl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($cUrl, CURLOPT_TIMEOUT, 'timeout_in_seconds'); curl_setopt($cUrl, CURLOPT_PROXY, 'proxy_ip:proxy_port'); $pageContent = trim(curl_exec($cUrl)); curl_close($cUrl); Hope this post will be useful Sincerely yours Vitali Simsive P.S. The example of working script can be seen here http://proxy-list.org/admin/checkproxy.php?proxy=’ip:port’&timeout=sec If somebody is interesting to obtain personal copy of checkproxy.php please mail me. ---- Manual Page -- http://www.php.net/manual/en/ref.curl.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+59481 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+59481&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+59481&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+59481&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+59481&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+59481&report=yes&reason=non-english Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+59481&report=yes&reason=already+in+docs Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+59481&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+59481&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#99727) next »