Welcome Guest, Not a member yet? Register   Sign In
Getting file contents over a proxy
#1

[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 Wink

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.
#2

[eluser]pistolPete[/eluser]
Did you try cURL? http://www.higherpass.com/php/tutorials/...Servers/3/
#3

[eluser]Boris Strahija[/eluser]
[quote author="pistolPete" date="1256088696"]Did you try cURL? http://www.higherpass.com/php/tutorials/...Servers/3/[/quote]
Not yet, but I will try it out for sure tomorrow Wink




Theme © iAndrew 2016 - Forum software by © MyBB