PHP Code To Access A Webpage Using Proxy


Are you looking for a php code to access a website using a proxy server with PHP.Here i am going to explain the simplest php code to read a webpages using proxy with PHP function  file_get_contents()
Code :
<?php
$aContext = array(
'http' => array(
'proxy' => 'tcp://84.201.212.38:3128', // proxy here
'request_fulluri' => true,
),
);
$cxContext = stream_context_create($aContext);
$sFile = file_get_contents("http://www.yahoo.com/", False, $cxContext); // webapge here
echo $sFile;
?>

No comments:

Post a Comment

Post Your valuable comments here ..........