is not working

Recommend this page to a friend!

      PHP Get HTTP Status Code from URL  >  All threads  >  is not working  >  (Un) Subscribe thread alerts  
Subject:is not working
Summary:fatal error
Messages:9
Author:synthetron
Date:2019-03-08 14:00:58
 

  1. is not working   Reply   Report abuse  
Picture of synthetron synthetron - 2019-03-08 14:00:58
Fatal error: Class 'httpStatus' not found in C:\wamp\www\php\phpstatus\example.php on line 11
Call Stack
# Time Memory Function Location
1 0.0004 672360 {main}( ) ..\example.php:0

  2. Re: is not working   Reply   Report abuse  
Picture of synthetron synthetron - 2019-03-08 14:15:03 - In reply to message 1 from synthetron
is not working for https sites

  3. Re: is not working   Reply   Report abuse  
Picture of Jason Olson Jason Olson - 2019-03-08 18:42:22 - In reply to message 2 from synthetron
Two things possibly come to mind:

1) CURL is not installed or configured; or
2) You're having a problem with certificates on XAMPP, which is common.

Try this:

Within the Class, just before curl_close($ch), add the following code:
print curl_error($ch);

That will tell you what is going on. Reply back with what you get from that statement.

Thanks,

Jason Olson

  4. Re: is not working   Reply   Report abuse  
Picture of synthetron synthetron - 2019-03-08 19:25:31 - In reply to message 3 from Jason Olson
SSL certificate problem, verify that the CA cert is OK. Details: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failedhttps://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html 0
SSL certificate problem, verify that the CA cert is OK. Details: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failedhttps://www.google.com 0

  5. Re: is not working   Reply   Report abuse  
Picture of synthetron synthetron - 2019-03-08 19:30:33 - In reply to message 4 from synthetron
can you add in phpstatus.php

curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, 0);

stackoverflow.com/questions/6400300 ...

  6. Re: is not working   Reply   Report abuse  
Picture of synthetron synthetron - 2019-03-08 19:36:55 - In reply to message 5 from synthetron

curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, true);
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, false);

curl_exec($ch);


w3.org/Protocols/rfc2616/rfc2616-se ... 200
google.com 200
google.com 200

  7. Re: is not working   Reply   Report abuse  
Picture of Jason Olson Jason Olson - 2019-03-22 17:14:38 - In reply to message 5 from synthetron
So if I understand you, you're using this on XAMPP, correct? And that you see that by disabling SSL verification that it is working. Fundamentally that would be reducing the security of the class, but at the same time I can see how it would be a limiting factor. There might be poeple who use self-signed certificates which need to properly sort out the HTTP response code, regardless of the invalid cert. Also it illustrates some error catching that might be necessary. Let me work on this a bit.

  8. Re: is not working   Reply   Report abuse  
Picture of synthetron synthetron - 2019-03-22 18:23:21 - In reply to message 7 from Jason Olson
i use wamp
and also ubuntu

it works fine now

  9. Re: is not working   Reply   Report abuse  
Picture of synthetron synthetron - 2019-03-22 19:12:04 - In reply to message 8 from synthetron
some things you can add

// $status = curl_getinfo($ch, CURLINFO_HTTP_CODE)." ". curl_getinfo($ch, CURLINFO_CONNECT_TIME) ." ". curl_getinfo($ch,CURLINFO_PRIMARY_IP) ." ". curl_getinfo($ch,CURLINFO_CONTENT_TYPE );






function getStatus($url) {

$http = new httpStatus();
$status = $http->status($url);
echo "<a href=".$url. " target=_blank>".$url."</a> ". $status."<br>";

}


getStatus("https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html");

getStatus("https://www.google.com");
getStatus("http://www.google.com");

 

For more information send a message to info at phpclasses dot org.