Hi, 
I have a problem. I'm posting some XML data to my client's website using HTTP 
Post. Assume I'm posting to getxml.php (hosted on my clients server). Now my 
client has put authentication on his website using 
header('WWW-Authenticate: Basic realm="Private Area"'); 

Now the page getxml.php asks me to prove my identity before it acceps my xml 
posts. 
So how do I send the username & pwd when I'm posting the xml details? 
My client doesn't want to forego this authentication concept. 

To post, this is what I'm doing 

------------------------------------------------------ 
function dopost( $host, $usepath, $postdata = "", $logfilename ) { 
//Global $logfilename; 
// 
// open socket to files that accept posts on other servers 
// 
$fp = fsockopen( $host, 80, &$errno, &$errstr, 60 ); 
// 
// check that the socket has been opened successfully 
// 
if( !$fp ) { 
//print "---------$errstr ($errno)---------<br>\n"; 
$this->postURL = "http://".$host.$usepath."?".$postdata; 
$this->writeToErrorLog($logfilename); 
} 
else { 

#write the data to the encryption cgi 
fputs( $fp, "POST $usepath HTTP/1.0\n"); 
$strlength = strlen( $postdata ); 
fputs( $fp, "Content-type: application/x-www-form-urlencoded\n" ); 
fputs( $fp, "Content-length: ".$strlength."\n\n" ); 
fputs( $fp, $postdata."\n\n" ); 
// 
// clear the response data 
// 
$output = ""; 


// 
// read the response from the remote cgi 
// 
// while content exists, keep retrieving document in 1K chunks 
// 
while( !feof( $fp ) ) { 
$output .= fgets( $fp, 1024); 
} 
// 
// close the socket connection 
// 
fclose( $fp); 
} 
// 
// return the response 
// 
return $output; 
} 

------------------------------------------------------ 
Also I have tried the following, still it doesn't work 

fputs( $fp, "POST $usepath HTTP/1.0\n"); 
$strlength = strlen( $postdata ); 
//fputs( $fp, "Authorization: " . base64_encode ( $username . ":" . 
$password) . "\n"); 
//fputs( $fp, "Authorization: " . base64_encode ("guest:guest")."\n"); 
fputs( $fp, "Authorization: " . "guest:guest"."\n"); 
fputs( $fp, "Content-type: application/x-www-form-urlencoded\n" ); 

fputs( $fp, "Content-length: ".$strlength."\n\n" ); 
fputs( $fp, $postdata."\n\n" ); 

Still nothing works out.. 
Plz help me. I need this badly now.

Regards
TNP
Professional Services
ZUSTEK INDIA
______________________________________________________________________________


---------- Original Message -----------
From: [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: 12 May 2004 09:51:48 -0000
Subject: WELCOME to [EMAIL PROTECTED]

> Hi! This is the ezmlm program. I'm managing the
> [EMAIL PROTECTED] mailing list.
> 
> I'm working for my owner, who can be reached
> at [EMAIL PROTECTED]
> 
> Acknowledgment: I have added the address
> 
>    [EMAIL PROTECTED]
> 
> to the php-general mailing list.
> 
> Welcome to [EMAIL PROTECTED]
> 
> Please save this message so that you know the address you are
> subscribed under, in case you later want to unsubscribe or change 
> your subscription address.
> 
> --- Administrative commands for the php-general list ---
> 
> I can handle administrative requests automatically. Please
> do not send them to the list address! Instead, send
> your message to the correct command address:
> 
> For help and a description of available commands, send a message to:
>    <[EMAIL PROTECTED]>
> 
> To subscribe to the list, send a message to:
>    <[EMAIL PROTECTED]>
> 
> To remove your address from the list, just send a message to
> the address in the ``List-Unsubscribe'' header of any list
> message. If you haven't changed addresses since subscribing,
> you can also send a message to:
>    <[EMAIL PROTECTED]>
> 
> or for the digest to:
>    <[EMAIL PROTECTED]>
> 
> For addition or removal of addresses, I'll send a confirmation
> message to that address. When you receive it, simply reply to it
> to complete the transaction.
> 
> If you need to get in touch with the human owner of this list,
> please send a message to:
> 
>     <[EMAIL PROTECTED]>
> 
> Please include a FORWARDED list message with ALL HEADERS intact
> to make it easier to help you.
> 
> --- Enclosed is a copy of the request I received.
> 
> Return-Path: <[EMAIL PROTECTED]>
> 
> Received: (qmail 64646 invoked by uid 1010); 12 May 2004 09:51:48 -0000
> Delivered-To: ezmlm-scan-php-general-
> [EMAIL PROTECTED]
> Delivered-To: ezmlm-php-general-sc.1084355448.dihjfmikeehgilooihaa-
> [EMAIL PROTECTED]
> Received: (qmail 64579 invoked from network); 12 May 2004 09:51:46 -0000
> Received: from unknown (HELO osi-tech.com) (203.199.179.83)
>   by pb1.pair.com with SMTP; 12 May 2004 09:51:46 -0000
> Received: from osi-tech.com (osi-tech.com [127.0.0.1])
>       by osi-tech.com (8.11.6/8.11.6) with ESMTP id i4C9wB914286
> 
>       for <php-general-sc.1084355448.dihjfmikeehgilooihaa-nthumuluru=osi-
> [EMAIL PROTECTED]>; Wed, 12 May 2004 15:28:11 +0530 From: 
> "Nagendra Prasad" <[EMAIL PROTECTED]> To: php-general-
> [EMAIL PROTECTED]
> Reply-To: [EMAIL PROTECTED]
> Subject: Re: confirm subscribe to [EMAIL PROTECTED]
> Date: Wed, 12 May 2004 15:28:11 +0530
> Message-Id: <[EMAIL PROTECTED]>
> In-Reply-To: <[EMAIL PROTECTED]>
> References: <[EMAIL PROTECTED]>
> X-Mailer: Open WebMail 2.10 20030617
> X-OriginatingIP: 203.199.179.82 (nthumuluru)
> MIME-Version: 1.0
> Content-Type: text/plain;
>       charset=iso-8859-1
> 
> -------- Original Message -----------
> From: [EMAIL PROTECTED]
> To: [EMAIL PROTECTED]
> Sent: 12 May 2004 09:50:48 -0000
> Subject: confirm subscribe to [EMAIL PROTECTED]
> 
> > Hi! This is the ezmlm program. I'm managing the
> > [EMAIL PROTECTED] mailing list.
> > 
> > I'm working for my owner, who can be reached
> > at [EMAIL PROTECTED]
> > 
> > To confirm that you would like
> > 
> >    [EMAIL PROTECTED]
> > 
> > added to the php-general mailing list, please send
> > an empty reply to this address:
> > 
> >    php-general-sc.1084355448.dihjfmikeehgilooihaa-nthumuluru=osi-
> [EMAIL PROTECTED]
> > 
> > Usually, this happens when you just hit the "reply" button.
> > If this does not work, simply copy the address and paste it into
> > the "To:" field of a new message.
> > 
> > or click here:
> >     mailto:php-general-sc.1084355448.dihjfmikeehgilooihaa-
> > [EMAIL PROTECTED]
> > 
> > This confirmation serves two purposes. First, it verifies that I am able
> > to get mail through to you. Second, it protects you in case someone
> > forges a subscription request in your name.
> > 
> > Some mail programs are broken and cannot handle long addresses. If 
> > you cannot reply to this request, instead send a message to <php-
> > [EMAIL PROTECTED]> and put the entire address listed 
> > above into the "Subject:" line.
> > 
> > --- Administrative commands for the php-general list ---
> > 
> > I can handle administrative requests automatically. Please
> > do not send them to the list address! Instead, send
> > your message to the correct command address:
> > 
> > For help and a description of available commands, send a message to:
> >    <[EMAIL PROTECTED]>
> > 
> > To subscribe to the list, send a message to:
> >    <[EMAIL PROTECTED]>
> > 
> > To remove your address from the list, just send a message to
> > the address in the ``List-Unsubscribe'' header of any list
> > message. If you haven't changed addresses since subscribing,
> > you can also send a message to:
> >    <[EMAIL PROTECTED]>
> > 
> > or for the digest to:
> >    <[EMAIL PROTECTED]>
> > 
> > For addition or removal of addresses, I'll send a confirmation
> > message to that address. When you receive it, simply reply to it
> > to complete the transaction.
> > 
> > If you need to get in touch with the human owner of this list,
> > please send a message to:
> > 
> >     <[EMAIL PROTECTED]>
> > 
> > Please include a FORWARDED list message with ALL HEADERS intact
> > to make it easier to help you.
> > 
> > --- Enclosed is a copy of the request I received.
> > 
> > Return-Path: <[EMAIL PROTECTED]>
> > 
> > Received: (qmail 59778 invoked by uid 1010); 12 May 2004 09:50:48 -0000
> > Delivered-To: ezmlm-scan-php-general-subscribe-nthumuluru=osi-
> [EMAIL PROTECTED]
> > Delivered-To: ezmlm-php-general-subscribe-nthumuluru=osi-
> [EMAIL PROTECTED]
> > 
> > Received: (qmail 59728 invoked from network); 12 May 2004 09:50:48 -0000
> > Received: from unknown (HELO rn2.php.net) (67.72.78.18)
> >   by pb1.pair.com with SMTP; 12 May 2004 09:50:48 -0000
> > 
> > Received: (qmail 22222 invoked by uid 522); 12 May 2004 09:48:50 -0000
> > Date: 12 May 2004 09:48:50 -0000 Message-ID: 
> <[EMAIL PROTECTED]>
> > To: [EMAIL PROTECTED]
> > Subject: PHP Mailing List Website Subscription
> > From: [EMAIL PROTECTED]
> > 
> > This was a request generated from the form at 
> > http://in2.php.net/mailing-lists.php by 203.199.179.82.
> ------- End of Original Message -------
------- End of Original Message -------

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to