Without proxy:
<?php $fp = fsockopen("www.wahoo.com",80); fputs($fp, "GET <a href=\"http://www.yahoo.com/\" " ."title=\"http://www.yahoo.com/\">http://www.yahoo.com/</a> HTTP/1.0\r\n\r\n"); $data=""; while (!feof($fp)) $data.=fgets($fp,64000); fclose($fp); print $data; ?>
With proxy:
<?php $ip = "1.2.3.4"; // proxy IP, change this according to your proxy setting $port = 1234; // proxy port, change this according to your proxy setting $fp = fsockopen($ip,$port); // connect to proxy fputs($fp, "GET <a href=\"http://www.yahoo.com/\" " . "title=\"http://www.yahoo.com/\">http://www.yahoo.com/</a> " . "HTTP/1.0\r\nHost:www.yahoo.com:80\r\n\r\n"); $data=""; while (!feof($fp)) $data.=fgets($fp,64000); fclose($fp); print $data; ?>
With proxy server and authentication:
<?php $ip = "1.2.3.4"; // proxy IP, change this according to your proxy setting $port = 1234; // proxy port, change this according to your proxy setting $fp = fsockopen($ip,$port); // connect to proxy $login = "Alexander"; // login name $passwd = "kiss me"; // password fputs($fp, "GET <a href=\"http://www.yahoo.com/\" " . "title=\"http://www.yahoo.com/\">http://www.yahoo.com/</a> HTTP/1.1\r\n" . "Host:www.yahoo.com:80\r\n" . "Proxy-Authorization: Basic ".base64_encode("$login:$passwd") ."\r\n\r\n"); $data=""; while (!feof($fp)) $data.=fgets($fp,64000); fclose($fp); //12314 print $data; ?>
Take a look here: Fsockopen with proxy server
source share