Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I don't know if you can use <code>get_headers</code> with https.</p> <p>But as an alternative (if you have Curl enabled) you can use the following function:</p> <pre><code>function getheaders($url) { $c = curl_init(); curl_setopt($c, CURLOPT_HEADER, true); curl_setopt($c, CURLOPT_NOBODY, true); curl_setopt($c, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($c, CURLOPT_SSL_VERIFYHOST, true); curl_setopt($c, CURLOPT_URL, $url); $headers = curl_exec($c); curl_close($c); return $headers; } </code></pre> <p>If you just need the HTTP status code you can modify the function like this:</p> <pre><code>function getstatus($url) { $c = curl_init(); curl_setopt($c, CURLOPT_HEADER, true); curl_setopt($c, CURLOPT_NOBODY, true); curl_setopt($c, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($c, CURLOPT_SSL_VERIFYHOST, true); curl_setopt($c, CURLOPT_URL, $url); curl_exec($c); $status = curl_getinfo($c, CURLINFO_HTTP_CODE); curl_close($c); return $status; } </code></pre> <p>If you don't have Curl you could try the following function:</p> <pre><code>&lt;?php function my_get_headers($url ) { $url_info=parse_url($url); if (isset($url_info['scheme']) &amp;&amp; $url_info['scheme'] == 'https') { $port = 443; @$fp=fsockopen('ssl://'.$url_info['host'], $port, $errno, $errstr, 10); } else { $port = isset($url_info['port']) ? $url_info['port'] : 80; @$fp=fsockopen($url_info['host'], $port, $errno, $errstr, 10); } if($fp) { stream_set_timeout($fp, 10); $head = "HEAD ".@$url_info['path']."?".@$url_info['query']; $head .= " HTTP/1.0\r\nHost: ".@$url_info['host']."\r\n\r\n"; fputs($fp, $head); while(!feof($fp)) { if($header=trim(fgets($fp, 1024))) { $sc_pos = strpos( $header, ':' ); if( $sc_pos === false ) { $headers['status'] = $header; } else { $label = substr( $header, 0, $sc_pos ); $value = substr( $header, $sc_pos+1 ); $headers[strtolower($label)] = trim($value); } } } return $headers; } else { return false; } } ?&gt; </code></pre> <p>Note that for HTTPS support you should have SSL support enabled. (uncomment extension=php_openssl.dll in php.ini).</p> <p>If you can't edit your php.ini and don't have SSL support it will be difficult to get the (encrypted) headers.</p> <p>You can check your wrappers (openssl and httpd) with:</p> <pre><code>$w = stream_get_wrappers(); echo 'openssl: ', extension_loaded ('openssl') ? 'yes':'no', "&lt;br&gt;\n"; echo 'http wrapper: ', in_array('http', $w) ? 'yes':'no', "&lt;br&gt;\n"; echo 'https wrapper: ', in_array('https', $w) ? 'yes':'no', "&lt;br&gt;\n"; echo 'wrappers: &lt;pre&gt;', var_dump($w), "&lt;br&gt;"; </code></pre> <p>You can check <a href="https://stackoverflow.com/questions/1975461/file-get-contents-with-https">this question</a> on SO for a similar problem.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload