Last active
March 8, 2018 12:37
-
-
Save jhammann/7229987149869adca0e67e9443013985 to your computer and use it in GitHub Desktop.
Detect the status of any webpage by sending an encoded URL as a query string. This returns a code as JSON.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
header('Content-type: text/json'); | |
header('Content-type: application/json'); | |
$url = urldecode($_GET['url']); | |
$ch = curl_init($url); | |
curl_setopt($ch, CURLOPT_HEADER, true); | |
curl_setopt($ch, CURLOPT_NOBODY, true); | |
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); | |
curl_setopt($ch, CURLOPT_TIMEOUT,10); | |
$output = curl_exec($ch); | |
$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE); | |
curl_close($ch); | |
$responseArray['status'] = $httpcode; | |
echo json_encode($responseArray); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment