Page 1 of 1

proxy acthentication error

Posted: Mon Oct 23, 2006 7:54 am
by ravi
JayBird | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


I am trying to access the  xml file from the other site, the code of ther program is below

Code: Select all

<?php

// Define a context for HTTP.
$aContext = array(
   'http' => array(
       'proxy' => "tcp://172.16.16.3:8080", // This needs to be the server and the port of the NTLM Authentication      Proxy Server.
       'request_fulluri' => True,
        'userid'=>"bravi",
        'password'=>"bravi123"

       ),
   );
$cxContext = stream_context_create($aContext);

// Now all file stream functions can use this context.

$sFile = file_get_contents("http://www.rediff.com/rss/inrss.xml", False, $cxContext);

echo $sFile;
?>

Code: Select all

Warning: file_get_contents(http://www.rediff.com/rss/inrss.xml) [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 C:\webs\test\simple.php on line 20

it is giving the above error how to set the proxy authentication.
my system details are username ="bravi" and password ="bravi123"
my proxy server address is 172.16.16.3 and port is 8080.
1)how to set the paramerters to access the xml file.
2)can you send me the excetuted code.

thanks in advance
ravi


JayBird | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Posted: Mon Oct 23, 2006 8:04 am
by volka
I'm unfamiliar with ISA. What made you think you can simply add 'userid'=>"bravi", 'password'=>"bravi123" to the stream context? (real question, source of idea please).

Posted: Mon Oct 23, 2006 8:55 am
by ravi
It is my idea for setting the username and password.

Posted: Mon Oct 23, 2006 9:21 am
by volka
Ok, there's no source for that idea, just your ...imagination ;)

If it's a "standard" proxy authentication as described in http://www.w3.org/Protocols/rfc2616/rfc ... l#sec14.34 these values needs to be put in the "header" field of the stream context array, see http://de2.php.net/manual/en/wrappers.h ... #AEN267530

please try

Code: Select all

<?php
// Define a context for HTTP.
$aContext = array(
   'http' => array(
       'proxy' => "tcp://172.16.16.3:8080", // This needs to be the server and the port of the NTLM Authentication      Proxy Server.
       'request_fulluri' => True,
        'userid'=>"bravi",
        'password'=>"bravi123"

       ),
   );
$cxContext = stream_context_create($aContext);

$sd = fopen('http://www.rediff.com/rss/inrss.xml', 'rb', $cxContext);

echo "<pre>\nmeta_data:\n";
print_r(stream_get_meta_data($sd));
echo "#\n</pre>\n";
?>

proxy authentication error

Posted: Tue Oct 24, 2006 12:40 am
by ravi
Thank you volka

I do not know how to set the header fields.I read the given help but not specified how to set the
pxoxy authentication in the header . Can you help me by setting the code with
following information
user name=bravi
password=bravi123

Posted: Tue Oct 24, 2006 12:44 am
by ravi
thank you volka,
i don't know how to set the header fields.I read the material but i did not get the idea how to set the
user name and password .Can you help me to how to set those parameters

thanks in advance
ravikumar

proxy authentication error

Posted: Tue Oct 24, 2006 12:46 am
by ravi
thank you volka,
i don't know how to set the header fields.I read the material but i did not get the idea how to set the
user name and password .Can you help me to how to set those parameters

thanks in advance
ravikumar

Posted: Tue Oct 24, 2006 3:38 am
by volka
volka wrote:please try

Code: Select all

<?php
// Define a context for HTTP.
$aContext = array(
   'http' => array(
       'proxy' => "tcp://172.16.16.3:8080", // This needs to be the server and the port of the NTLM Authentication      Proxy Server.
       'request_fulluri' => True,
        'userid'=>"bravi",
        'password'=>"bravi123"

       ),
   );
$cxContext = stream_context_create($aContext);

$sd = fopen('http://www.rediff.com/rss/inrss.xml', 'rb', $cxContext);

echo "<pre>\nmeta_data:\n";
print_r(stream_get_meta_data($sd));
echo "#\n</pre>\n";
?>

Posted: Tue Oct 24, 2006 4:05 am
by ravi

Code: Select all

Warning: fopen() expects parameter 3 to be boolean, resource given in C:\webs\test\index.php on line 14

meta_data:


Warning:  stream_get_meta_data(): supplied argument is not a valid stream resource in C:\webs\test\index.php on line 16

#

Posted: Tue Oct 24, 2006 4:23 am
by volka
$sd = fopen('http://www.rediff.com/rss/inrss.xml', 'rb', false, $cxContext);