php - Checking if website is down using curl -
i using following code see if website down or not.
<?php if (isset($_post['submit'])) { $url = $_post['url']; $curl = curl_init($url); curl_setopt($curl, curlopt_nobody, true); curl_setopt($curl, curlopt_followlocation, true); curl_exec($curl); $code = curl_getinfo($curl, curlinfo_http_code); if ($code == 200) { echo "<h3>up!</h3>"; } else { echo "<h3>down!</h3>"; } } ?> <form action="" method="post"> url: <input type="text" name="url" /><br /> <input type="submit" name="submit" /> </form>
the issue having when check facebook.com says down isn't...
why doing this? orginally thought https google works fine.
i believe curl isn't following http redirects, means you'll receive 301 response facebook.
here's thread on how make curl follow redirects:
Comments
Post a Comment