Hi I'm trying to add private proxy support to a PHP class that is using fsockopen rather than cURL and I'm a bit lost with it!
I have the following code which is producing an error warning for each of the fputs lines:
fputs(): supplied argument is not a valid stream resource
Any help would be really appreciated.
$proxyServer = '173.208.43.223';
$proxyPort = '8800';
$login = 'myuser'; // login name
$passwd = 'mypassword'; // password
$ptr = @fsockopen($proxyServer, $proxyPort, $errno, $errstr, $this->STIMEOUT);
fputs($ptr,"Proxy-Authorization: Basic ".base64_encode("$login:$passwd") ."\r\n");
$uri = $server.":".$port;
fputs($ptr, 'GET '.$uri.' HTTP/1.0'."\r\n");
You should check whether $ptr is false or not and break if it is false. Be sure to use a strict comparison (===).
And if you remove the @-sign you will see the error messages. An @-sign is normally an indicator for bad code.