Go Back   Forum Care Forums > Development Reference Area > Php Development

Reply
 
LinkBack Thread Tools Display Modes
file_get_contents and https
Old
  (#1)
Bob Hanson
Guest
 
Posts: n/a
Default file_get_contents and https - 06-02-2007, 08:56 PM

I am new to PHP; using Apache 2.2 and PHP 5/Windows. I'd like to do this:

$x = file_get_contents("https://userEMAIL REMOVED")

I get:

Warning: file_get_contents(https://...) [function.file-get-contents]:
failed to open stream: Invalid argument in ... on line...

I think I have the following correct:

1) I have php_openssl.dll present and indicated as an extension in the
ext directory
2) libeay32.dll is on the Windows path

What more do I need to do?

Thanks,


Bob Hanson


--
Robert M. Hanson
Professor of Chemistry
St. Olaf College
Northfield, MN
http://www.stolaf.edu/people/hansonr


If nature does not answer first what we want,
it is better to take what answer we get.

-- Josiah Willard Gibbs, Lecture XXX, Monday, February 5, 1900
   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

RE: [PHP] file_get_contents and https
Old
  (#2)
Jay Blanchard
Guest
 
Posts: n/a
Default RE: [PHP] file_get_contents and https - 06-02-2007, 08:56 PM

[snip]
I am new to PHP; using Apache 2.2 and PHP 5/Windows. I'd like to do
this:

$x = file_get_contents("https://userEMAIL REMOVED")

I get:

Warning: file_get_contents(https://...) [function.file-get-contents]:
failed to open stream: Invalid argument in ... on line...
[/snip]

The warning that you get is "Invalid argument..." Have you read
http://us2.php.net/file_get_contents to make sure that you are including
all needed arguments?
   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Re: [PHP] file_get_contents and https
Old
  (#3)
Bob Hanson
Guest
 
Posts: n/a
Default Re: [PHP] file_get_contents and https - 06-02-2007, 08:56 PM

Thanks, Jay.

I tried it first with a simple "http://" call, and that worked fine. So
unless "https:..." requires something additional in the way of
arguments, that doesn't seem to be the issue.

I'm hoping someone who has done this remembers what special installation
issues there might be. When I look on the web I see lots of discussion,
but it's pretty hard to figure out how much of it is currently
applicable and how much of it is ancient history.

Bob


Jay Blanchard wrote:

>[snip]
>I am new to PHP; using Apache 2.2 and PHP 5/Windows. I'd like to do
>this:
>
>$x = file_get_contents("https://userEMAIL REMOVED")
>
>I get:
>
>Warning: file_get_contents(https://...) [function.file-get-contents]:
>failed to open stream: Invalid argument in ... on line...
>[/snip]
>
>The warning that you get is "Invalid argument..." Have you read
>http://us2.php.net/file_get_contents to make sure that you are including
>all needed arguments?
>
>

The URL for file_get_contents doesn't give many clues to its use with
https.


--
Robert M. Hanson
Professor of Chemistry
St. Olaf College
Northfield, MN
http://www.stolaf.edu/people/hansonr


If nature does not answer first what we want,
it is better to take what answer we get.

-- Josiah Willard Gibbs, Lecture XXX, Monday, February 5, 1900
   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Re: [PHP] file_get_contents and https
Old
  (#4)
Stut
Guest
 
Posts: n/a
Default Re: [PHP] file_get_contents and https - 06-02-2007, 08:56 PM

Bob Hanson wrote:
> Thanks, Jay.
>
> I tried it first with a simple "http://" call, and that worked fine. So
> unless "https:..." requires something additional in the way of
> arguments, that doesn't seem to be the issue.
>
> I'm hoping someone who has done this remembers what special installation
> issues there might be. When I look on the web I see lots of discussion,
> but it's pretty hard to figure out how much of it is currently
> applicable and how much of it is ancient history.


Was PHP built with openssl enabled? If not, that's ya problem.

-Stut

> Jay Blanchard wrote:
>
>> [snip]
>> I am new to PHP; using Apache 2.2 and PHP 5/Windows. I'd like to do
>> this:
>>
>> $x = file_get_contents("https://userEMAIL REMOVED")
>>
>> I get:
>>
>> Warning: file_get_contents(https://...) [function.file-get-contents]:
>> failed to open stream: Invalid argument in ... on line...
>> [/snip]
>>
>> The warning that you get is "Invalid argument..." Have you read
>> http://us2.php.net/file_get_contents to make sure that you are including
>> all needed arguments?
>>
>>

> The URL for file_get_contents doesn't give many clues to its use with
> https.
>
>

   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Re: [PHP] file_get_contents and https
Old
  (#5)
David Giragosian
Guest
 
Posts: n/a
Default Re: [PHP] file_get_contents and https - 06-02-2007, 08:56 PM

On 5/31/07, Stut <EMAIL REMOVED> wrote:
>
> Bob Hanson wrote:
> > Thanks, Jay.
> >
> > I tried it first with a simple "http://" call, and that worked fine. So
> > unless "https:..." requires something additional in the way of
> > arguments, that doesn't seem to be the issue.
> >
> > I'm hoping someone who has done this remembers what special installation
> > issues there might be. When I look on the web I see lots of discussion,
> > but it's pretty hard to figure out how much of it is currently
> > applicable and how much of it is ancient history.

>
> Was PHP built with openssl enabled? If not, that's ya problem.



phpinfo() is your friend.

-Stut
>
> > Jay Blanchard wrote:
> >
> >> [snip]
> >> I am new to PHP; using Apache 2.2 and PHP 5/Windows. I'd like to do
> >> this:
> >>
> >> $x = file_get_contents("https://userEMAIL REMOVED")
> >>
> >> I get:
> >>
> >> Warning: file_get_contents(https://...) [function.file-get-contents]:
> >> failed to open stream: Invalid argument in ... on line...
> >> [/snip]
> >>
> >> The warning that you get is "Invalid argument..." Have you read
> >> http://us2.php.net/file_get_contents to make sure that you are

> including
> >> all needed arguments?
> >>
> >>

> > The URL for file_get_contents doesn't give many clues to its use with
> > https.



David

   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Re: [PHP] file_get_contents and https
Old
  (#6)
Bob Hanson
Guest
 
Posts: n/a
Default Re: [PHP] file_get_contents and https - 06-02-2007, 08:56 PM

Problem solved. Thank you all very much for such quick responses.

The solution was to get ssleay32.dll from the PHP 5 ZIP distribution and
put in my PHP directory.

For the record:

With Windows and PHP 5 all that is needed to use the https protocol in
file_get_contents is to make sure that both

libeay32.dll
ssleay32.dll

are on the Windows path, which in my case includes the path to my PHP
directory, so I just put them there.

Excellent! Many thanks.

Bob Hanson
   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

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




Contact Us - Forum Care Forums - Archive - Top