Current location: Hot Scripts Forums » Programming Languages » PHP » Problem with https and meta data


Problem with https and meta data

Reply
  #1 (permalink)  
Old 12-05-07, 02:46 PM
The_Demon The_Demon is offline
Newbie Coder
 
Join Date: Dec 2007
Location: The burning depths of hell
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
Unhappy Problem with https and meta data

Good (morning|evening|afternoon)

I am wondering if anyone can help me with a little problem I seem to be having
I am using fopen to open a stream to a url and get the meta data like so
PHP Code:

    $handle fopen($file,"r");

    
$meta_data=stream_get_meta_data($handle);
    
fclose($handle); 
this works great for files that are http but not for https files. does anyone know of a way i can work around this problem so that it allows me to retrieve meta data for https files?

Thanks
The Demon
Reply With Quote
  #2 (permalink)  
Old 12-05-07, 05:37 PM
Nico's Avatar
Nico Nico is offline
Community Leader
 
Join Date: Sep 2005
Location: Spain
Posts: 8,075
Thanks: 11
Thanked 88 Times in 83 Posts
Do you get any errors or warnings? Try setting the error reporting to E_ALL:
PHP Code:

error_reporting(E_ALL);
ini_set('display_errors''1'); 
Also, this is from php.net:
Quote:
When using SSL, Microsoft IIS will violate the protocol by closing the connection without sending a close_notify indicator. PHP will report this as "SSL: Fatal Protocol Error" when you reach the end of the data. To workaround this, you should lower your error_reporting level not to include warnings. PHP 4.3.7 and higher can detect buggy IIS server software when you open the stream using the https:// wrapper and will suppress the warning for you. If you are using fsockopen() to create an ssl:// socket, you are responsible for detecting and suppressing the warning yourself.
http://www.php.net/fopen
Reply With Quote
  #3 (permalink)  
Old 12-05-07, 05:46 PM
The_Demon The_Demon is offline
Newbie Coder
 
Join Date: Dec 2007
Location: The burning depths of hell
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
Thanks for the reply Nico

I tried with the code you supplied. this is the output from it
Code:
Warning: fopen(https://address.com) [function.fopen]: failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in C:\scripts\general\functions.php on line 15

Warning: stream_get_meta_data(): supplied argument is not a valid stream resource in C:\scripts\general\functions.php on line 16

Warning: fclose(): supplied argument is not a valid stream resource in C:\scripts\general\functions.php on line 17
Please note, address.com was not the actual URL
__________________
The Demon
Reply With Quote
  #4 (permalink)  
Old 12-05-07, 05:48 PM
Nico's Avatar
Nico Nico is offline
Community Leader
 
Join Date: Sep 2005
Location: Spain
Posts: 8,075
Thanks: 11
Thanked 88 Times in 83 Posts
Can you browse to the file with your web browser? Seems like the file does not exist:
Quote:
HTTP/1.1 404 Not Found
Does it give you an error when you for example try to open https://www.paypal.com/ ?
Reply With Quote
  #5 (permalink)  
Old 12-05-07, 06:03 PM
The_Demon The_Demon is offline
Newbie Coder
 
Join Date: Dec 2007
Location: The burning depths of hell
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
Ah, thanks Nico, I figured that out. It was simply a single char missing lol
Now it says I need to configure my php to enable the https wrapper
Code:
Notice: fopen() [function.fopen]: Unable to find the wrapper "https" - did you forget to enable it when you configured PHP? in C:\......
I'm using WAMP 1.7.3 on localhost at the moment. is there a https wrapper? and if so, could you be so kind as to enlighten me on how the heck I can install/enable it

Thankyou
__________________
The Demon
Reply With Quote
  #6 (permalink)  
Old 12-05-07, 06:12 PM
Nico's Avatar
Nico Nico is offline
Community Leader
 
Join Date: Sep 2005
Location: Spain
Posts: 8,075
Thanks: 11
Thanked 88 Times in 83 Posts
Open your php.ini file, and see if following line is uncommented:
Code:
extension=php_openssl.dll
If there's a semicolon (;) at the beginning, remove it, save the file, restart Apache, and try again.
Reply With Quote
  #7 (permalink)  
Old 12-05-07, 06:24 PM
The_Demon The_Demon is offline
Newbie Coder
 
Join Date: Dec 2007
Location: The burning depths of hell
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
Excellent
Many thanks
__________________
The Demon
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump


All times are GMT -5. The time now is 07:32 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.