1

I am developing a script which deal with accessing remote site data. For this purpose i am using file_get_contents() function. it was working fine in home but no connectivity in office. then after googling i found using proxy header with file_get_contents()

my script is as follow which i got from stackoverflow's thread file_get_contents()

$auth = base64_encode('mywindowlogin:password');

$opts = array('http' => array('proxy' => 'tcp://172.20.10.130:8080', 'request_fulluri'       => true,'header' => "Proxy-Authorization: Basic $auth",));
$context = stream_context_create($opts);

$data = file_get_contents('http://www.lesco.gov.pk/', false, $context);

echo $data;

this OUTPUT with an ERROR

[function.file-get-contents]: failed to open stream: HTTP request failed! 
HTTP/1.1 407 Proxy Authentication Required ( The ISA Server requires
authorization to fulfill the request. Access to the Web P in 
D:\php\docs\url.php on line 7

Real question Comes here that in office they are using ISA Proxy server and i am using PHP on apache

  1. do i need to use Window login as userid or something esle?
  2. i am doing something wrong while passing userid and password for proxy authorization? OR
  3. What i am doing is not the right way of doing it?

please suggest me how or what to do make file_get_contents working through proxy server. thanks in advance

Community
  • 1
  • 1

0 Answers0