Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
PHP - how to get headers of an HTTPS page?
Old 07-09-2012, 08:25 AM PHP - how to get headers of an HTTPS page?
Average Talker

Posts: 27
Name: paul
Trades: 0
hi,

i'd like to check the server headers (200/404/502) of an HTTPS page.

how do i do that in PHP?

the function get-headers doesn't support HTTPS.


thanks guys!
datrader is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 07-09-2012, 08:39 AM Re: PHP - how to get headers of an HTTPS page?
chrishirst's Avatar
Defies a Status

Posts: 44,044
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
The headers are encrypted so basically ..... you can't.
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 07-09-2012, 12:56 PM Re: PHP - how to get headers of an HTTPS page?
Physicsguy's Avatar
404 - Title not found

Posts: 1,066
Name: Scott Kaye
Location: Ontario
Trades: 0
I haven't tried it, but this looks like it might work:
http://php.net/manual/en/function.get-headers.php#55190
__________________

Please login or register to view this content. Registration is FREE
Physicsguy is online now
Reply With Quote
View Public Profile Visit Physicsguy's homepage!
 
Old 07-10-2012, 11:00 AM Re: PHP - how to get headers of an HTTPS page?
Novice Talker

Posts: 7
Trades: 0
You can use curl to get full headers:

PHP Code:
function getheaders($url) {
    
$c curl_init();
    
curl_setopt($cCURLOPT_HEADERtrue);
    
curl_setopt($cCURLOPT_NOBODYtrue);
    
curl_setopt($cCURLOPT_SSL_VERIFYPEERfalse);
    
curl_setopt($cCURLOPT_SSL_VERIFYHOSTtrue);
    
curl_setopt($cCURLOPT_URL$url);
    
$headers curl_exec($c);
    
curl_close($c);
    return 
$headers;

If it's just HTTP status code you need, you can modify the function like this:

PHP Code:
function getstatus($url) {
    
$c curl_init();
    
curl_setopt($cCURLOPT_HEADERtrue);
    
curl_setopt($cCURLOPT_NOBODYtrue);
    
curl_setopt($cCURLOPT_SSL_VERIFYPEERfalse);
    
curl_setopt($cCURLOPT_SSL_VERIFYHOSTtrue);
    
curl_setopt($cCURLOPT_URL$url);
    
curl_exec($c);
    
$status curl_getinfo($cCURLINFO_HTTP_CODE);
    
curl_close($c);
    return 
$status;

lafor is offline
Reply With Quote
View Public Profile
 
Old 07-10-2012, 04:28 PM Re: PHP - how to get headers of an HTTPS page?
chrishirst's Avatar
Defies a Status

Posts: 44,044
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Not what the question is about.

That code would get the RESPONSE headers from a remote site. The TS wants to get the REQUEST headers on the SAME server.
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 07-10-2012, 05:20 PM Re: PHP - how to get headers of an HTTPS page?
Novice Talker

Posts: 7
Trades: 0
The status codes OP mentioned are response codes. The get_headers() function OP mentioned returns response headers. I'm pretty sure he's after response but what do I know.
lafor is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to PHP - how to get headers of an HTTPS page?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.19069 seconds with 11 queries