I need to connect to a server via proxy server(s) using fsockopen. There is a list of proxies in a file called proxies.csv in the standard "IP:Port" format.
I pick a random one using this code:
Code: Select all
$data_file = fopen('proxies.csv', 'r');
while (!feof ($data_file)) {
$data_file_array = explode(':', fgets($data_file));
$ProxyIP[] = $data_file_array[0];
$ProxyPort[] = $data_file_array[1];
}
fclose ($data_file);Code: Select all
$fp = fsockopen($ProxyIP[0], $ProxyPort[0], $errno, $errstr, 30);Now there is a problem with $fp because if I use it as is, I get this error message:
Code: Select all
fsockopen() expects parameter 2 to be long, string given in...Code: Select all
$fp = fsockopen($ProxyIP[0], 80, $errno, $errstr, 30);Any idea what this could be caused by? I've tried just about everything and in my opinion, it should work. But it does not for some reason.
Thanks for any help!
Tomas