Page 1 of 1

Connecting via a Proxy - Help

Posted: Thu Apr 16, 2009 7:48 am
by mnuser
Hello All,

I am trying to change a php script that works already to connect via a proxy -

//Start////////////////////////////////////////////
$ProxyServer = "4.3.2.1";
$ProxyPort = 80;
$timeout=10;
//$fp = fsockopen("1.2.3.4", 80, $errno, $errstr, 30); // open socket to IMAREX data
$fp = fsockopen($ProxyServer ,$ProxyPort, $errno, $errstr, 30);
$fout = fopen("n:\support\config\bpits\imarex\imarex_xml.txt", "w+"); // open file in which we'll dump xml data
$fdate = fopen("n:\support\config\bpits\imarex\date.txt", "r"); // open file containing date we need to read in
$date = fgets($fdate, 128); // read in date for which we'll grab data
if (!$fp) { // check if we have a handle to site
echo "$errstr ($errno)<br />\n"; // if not show error
} else { // else....
$out = "GET /TradeNet/WebServices/PriceService.asmx/GetClosingPrices1?when=$date HTTP/1.1\r\n";
$out .= "Host: 1.2.3.4\r\n"; // keep building data request...
$out .= "Connection: Close\r\n\r\n"; // last line of data request
fwrite($fp, $out); // write data request to IMAREX
while (!feof($fp)) { // while they're sending...
$buffer = fgets($fp, 128); // grab a line at a time
fwrite($fout, $buffer); // & write it to our output file
}
}
fclose($fp);
fclose($fout);
//End/////////////////////////////////////////////////////////

I am new to php and would appreciate some help.

Thanks in advance.