note 51214 added to function.curl-setopt
| From: | azcappy at azcappy dot com | Date: | Wed, 23 Mar 2005 18:03:07 +0000 |
| Subject: | note 51214 added to function.curl-setopt | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-86852@lists.php.net to get a copy of this message | ||
AZAds is a traffic exchange that we wrote. We wanted to come up with a way to check the UP or DOWN
status of a submitted URL. Here is the solution we came up with. Can also be used for a site
monitoring service.
<?
$uServer="$url";
@$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "$uServer");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
@curl_exec($ch);
$errnum=curl_errno($ch);
@curl_close($ch);
if($errnum != "0") {
print "Remote Site Status: DOWN";
} else {
print "Remote Site Status: UP";
}
?>
Simply feed the URL to be tested into $url. The code will check the site and return the error code
if there is one and display to appropriate message.
Hope this is useful.
Keith
www.azads.net
----
Manual Page -- http://www.php.net/manual/en/function.curl-setopt.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+51214
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+51214&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+51214&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+51214&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+51214&report=yes&reason=useless
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+51214&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+51214&report=yes
Search -- http://master.php.net/manage/user-notes.php