Jump to content

Opening URLs as Files


rabark

Recommended Posts

I'm trying to open a URL via the file_get_contents method, but it's not working (throws the "failed to open stream: No such file or directory " message).  The phpinfo method shows that PHP has been configured with allow_url_fopen set to "On".

 

It should be noted however that I'm trying to access a "https" URL.  Does file_get_contents() work with https?

Link to comment
Share on other sites

Thank you for the quick replies  :)

 

To my knowledge, the page is not restricted in any way.  Also, I am able to copy and paste the URL from the warning message to the address bar and access the page (a bunch of XML) just fine.

 

Also, please post some code

 

My previous theory was that https doesn't work with file methods.  My current theory is that the problem lies somewhere on the server or network since I'm able to use it on some URLs but not others and I am sending emails back and forth to the administrator.  For what it's worth however, here is the code of interest (URL has been censored for privacy, but its structure is the same):

 

$url = "https://some.host.com:1234/directory/WebService.jws/mymethod?arg1=value1&arg2=value2&arg3=value3&";
$xml = file_get_contents($url);

print "This is what was returned:<br><br>";
print nl2br($xml);

 

 

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.