note 28758 added to ref.curl

From: Date: Thu, 23 Jan 2003 04:18:27 +0000
Subject: note 28758 added to ref.curl
Groups: php.notes 
Request: Send a blank email to php-notes+get-42623@lists.php.net to get a copy of this message
There is a site which uses curl to do a lot of automated link checking in a script is <a href="http://listbid.com/affil/>affiliate source</a> which seems to be pretty interesting in the script they use. Here is a modified version. function GetCurlPage ($pageSpec) { if(function_exists('curl_init'){ $agent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)"; $ref = "http://listbid.com/affil/"; $ch = curl_init($pageSpec); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_USERAGENT, $agent); curl_setopt($ch, CURLOPT_REFERER, $ref); $tmp = curl_exec ($ch); curl_close ($ch); $ret = $tmp; }else{ $ret = @implode('', @file ($pageSpec)); } return $ret; } This check if CURL is installed first before attempting to call it, this is for those of you who are not sure if it is. (shared hosting etc.) cheers -- http://www.php.net/manual/en/ref.curl.php http://master.php.net/manage/user-notes.php?action=edit+28758 http://master.php.net/manage/user-notes.php?action=delete+28758 http://master.php.net/manage/user-notes.php?action=reject+28758

« previous php.notes (#42623) next »