How do you use file_get_contents() on PhpStorm? - php

Usually, you could just enter the URL from a website to get the HTML code. However, on PhpStorm, when I try to do:
file_get_contents("http://localhost:63342/Prj1_Submission1/index.php?_ijt=i77g98br35guk27egnuaaj3va6")
where the URL is generated by PhpStorm for my index.php it gives me this error:
Warning: file_get_contents(http://localhost:63342/Prj1_Submission1/index.php?_ijt=i77g98br35guk27egnuaaj3va6): failed to open stream: HTTP request failed! in C:\Users\prajw\PhpstormProjects\Prj1_Submission1\search.php on line 18

Related

Image not loading, Failed to open stream: HTTP request failed

I have the following problem on a Magento2 Fresh installation with dummy data, using the theme [Revo]: https://themeforest.net/item/revo-responsive-magento-2-shopping-theme/18339484
Error filtering template: Warning:
getimagesize(https://website.com/media/wysiwyg/imageslider/slider-1.jpg):
failed to open stream: HTTP request failed! HTTP/1.1 401 Unauthorized
in
/var/www/html/nobacco/vendor/magento/framework/Image/Adapter/AbstractAdapter.php
on line 304
Permissions are correct, nginx settings seem good the image exists on the server and is accessible through the same url and the user rights seems alright too.. Any ideas?
Before this error I was getting an error on vendor/(cant remember the full path)/Image.php

PHP file_get_contents sometimes failed to open stream Http request failed

I have an ajax call that gets many, many pages of contents from a website, but it fails to open steams sometimes even though the same exact links that failed to open streams works just fine, when I ran them again. The problem is, then other links would failed to open stream. Anyone know why this is happening?
Warning: file_get_contents(http://www.merriam-webster.com/browse/dictionary/a/acoustically.htm): failed to open stream: HTTP request failed!

use get parameters in DOMDocument::loadHTMLFile()

I want to load an url like this using DOMDocument::loadHTMLFile(): http://www.domain.com/dir/page?param1=235235&param2=2345, but it gives this error, even though the page exists:
Warning: DOMDocument::loadHTMLFile(http://www.domain.com/dir/page?param1=235235&param2=2345): failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found
How can I solve this?

Error while invoking REST service

I am facing a strange problem. I am trying to integrate a REST api in phonegap application.
When I request the url say http://myserver/index.php?m=login via a rest client in my browser it works fine.
But when I invoke it via jQuery ajax it returns the following error:
Warning:
include(C:/Domains/my-portal.org/httpdocs/mmode/template/mobile/index.php)
[function.include]: failed to open stream: No such file or directory
in C:\Domains\my-portal.org\httpdocs\mmode\index.php on line 13
Warning: include(C:/Domains/my-portal.org/httpdocs/mmode/template/mobile/index.php)
[function.include]: failed to open stream: No such file or directory
in C:\Domains\my-portal.org\httpdocs\mmode\index.php on line 13
Warning: include() [function.include]: Failed opening 'C:/Domains/myportal.org/httpdocs/mmode/template/mobile/index.php' for inclusion (include_path='.;./includes;./pear;C:\PHP\includes') in C:\Domains\my-portal.org\httpdocs\mmode\index.php on line 13
Now the problem is not cross-domain scripting because the response header returns "Access-Control-Allow-Origin: *". And I have also white-listed the domain in cordova settings.
Can anyone please guide me what could be the problem here?

I'm having trouble getting file_get_contents() to work on my server

I've got a php file on my server that looks like this:
echo file_get_contents('http://server.com/some.file');
and I get the following error:
Warning: file_get_contents(http://server.com/some.file) [function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in /path/to/php/file on line 6
What's got me confused is that if I link to the/full/server/path instead of http:// it seems to load fine. Also, I can get it to load content from other domains using http://, just not my own.
Any ideas?
As deceze sayd test the path in a browser. It should work the same as in PHP. If the path you write is correct check your URL rewrites (maybe you have them different for the server IP).

Categories