Jump to content

fopen & urls


jgutierrez

Recommended Posts

Hello all,

 

I am running php 5.2.4 and 4.3.9 on the same machine that uses the same php.ini file. I run php 5.2.4 by doing the following at the command line:

 

[jgutierrez@jgutierrez] php5 <script_name>

 

and I run php 4.3.9 by doing the following

 

[jgutierrez@jgutierrez] php <script_name>

 

I am using 5.2.4 and trying use fopen() to fetch a web page. However, when I call fopen() with a url I get the following warning:

 

Warning: fopen(<url>): failed to open stream: No such file or directory.

 

I checked the php.ini file to see if the variable "allow_url_fopen" is set to "On" and it is. I can call fopen() on a different machine running 5.2.3-1 and I get the requested page. Is there something that I am missing? Any help/suggestions would be greatly appreciated. Thank you.

Link to comment
Share on other sites

Note: I had to alter the url because I am posting to a gateway owned by a billing company and the url is specific to my company.

 

<?php

$url = "https://someurl.com/api/?name=SERVICE&version=1.0&clientid=001&user_id=A001&password=password";

$http_handle = fopen($url, "r");

$response_contents = fread($http_handle, 512);

print_r($response_contents . "\n");

?>

 

Link to comment
Share on other sites

http://uk3.php.net/manual/en/function.fopen.php

 

Warning

 

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.

 

Further down is this, http://uk3.php.net/manual/en/function.fopen.php#58099

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.