[eluser]Boris Strahija[/eluser]
This is the situation. I have a list of proxy adresses, and they all require username and password. Now I need to get contents from a URL over those proxies. Choosing a proxy is not a problem, it will be done randomly, but nothing is working so far.
It's not really CI related, but it' actually part of a CI app
Here's my code:
Code:
$authProx = base64_encode("my_username:my_password");
$header = "Accept-language: en\r\n" .
"Proxy-Authorization: Basic {$authProx}" ;
$ctx = stream_context_create(array(
'http' => array(
'timeout' =>20
,'proxy' =>'tcp://xx.xx.xx.xx:xxxx'
,'request_fulluri' =>TRUE
,'header' =>$header
)
)
);
$scrape_data = file_get_contents('http://www.my_url.hr', FALSE, $ctx);
And the error I keep getting:
Code:
A PHP Error was encountered
Severity: Warning
Message: file_get_contents(http://www.my_url.hr) [function.file-get-contents]: failed to open stream: HTTP request failed!
Filename: libraries/torrentfile.php
Line Number: 678
Any help would be appreciated.