proxy acthentication error

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
ravi
Forum Newbie
Posts: 13
Joined: Tue Aug 31, 2004 12:30 am

proxy acthentication error

Post 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]
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post 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).
ravi
Forum Newbie
Posts: 13
Joined: Tue Aug 31, 2004 12:30 am

Post by ravi »

It is my idea for setting the username and password.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post 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";
?>
ravi
Forum Newbie
Posts: 13
Joined: Tue Aug 31, 2004 12:30 am

proxy authentication error

Post 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
ravi
Forum Newbie
Posts: 13
Joined: Tue Aug 31, 2004 12:30 am

Post 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
ravi
Forum Newbie
Posts: 13
Joined: Tue Aug 31, 2004 12:30 am

proxy authentication error

Post 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
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post 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";
?>
ravi
Forum Newbie
Posts: 13
Joined: Tue Aug 31, 2004 12:30 am

Post 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

#
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

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