I'm trying to fetch data from the Internet using PHP. Being at work, I'm behind a password protected proxy which seems to cause trouble.
I have consulted many posts on StackOverflow and several other platforms, each one giving me a different solution, none of which could fill my needs.
var_dump(stream_get_wrappers());
$opts = array("http" => ['proxy'=>'user:password@webproxy.xxx.intra:####',
'request_fulluri' => True]
);
stream_context_set_default($opts);
$homepage = file_get_contents("www.google.com");
echo $homepage;
I've added var_dump(stream_get_wrappers());
as advised in one of the posts I've previously read, returning : [https, ftps, compress.zlib, compress.bzip2, php, file, glob, data, http, ftp, phar, zip]
And the warning I get is the following :
PHP Warning: file_get_contents(www.google.com): failed to open stream: No such file or directory in /home/user/project/app/connector.php on line 15
Line 15 being $homepage = file_get_contents("www.google.com");
I've been stuck there for way too long, and any help is greatly appreciated.
Thank you.
EDIT : I have added "http://" to the beginning of the address, giving me this error :
PHP Warning: file_get_contents(google.com): failed to open stream: php_network_getaddresses: getaddrinfo failed: Name or service not known in /home/user/project/app/connector.php on line 15
For some reason this error got displayed twice, the second one being almost the same with less information.