Send username & password in HTTP headers

From: Date: Wed, 12 May 2004 10:00:17 +0000
Subject: Send username & password in HTTP headers
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-185961@lists.php.net to get a copy of this message
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: php-general-help@lists.php.net To: nthumuluru@osi-tech.com Sent: 12 May 2004 09:51:48 -0000 Subject: WELCOME to php-general@lists.php.net > Hi! This is the ezmlm program. I'm managing the > php-general@lists.php.net mailing list. > > I'm working for my owner, who can be reached > at php-general-owner@lists.php.net. > > Acknowledgment: I have added the address > > nthumuluru@osi-tech.com > > to the php-general mailing list. > > Welcome to php-general@lists.php.net! > > 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: > <php-general-help@lists.php.net> > > To subscribe to the list, send a message to: > <php-general-subscribe@lists.php.net> > > 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: > <php-general-unsubscribe@lists.php.net> > > or for the digest to: > <php-general-digest-unsubscribe@lists.php.net> > > 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: > > <php-general-owner@lists.php.net> > > 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: <nthumuluru@osi-tech.com> > > Received: (qmail 64646 invoked by uid 1010); 12 May 2004 09:51:48 -0000 > Delivered-To: ezmlm-scan-php-general- > sc.1084355448.dihjfmikeehgilooihaa-nthumuluru=osi-tech.com@lists.php.net > Delivered-To: ezmlm-php-general-sc.1084355448.dihjfmikeehgilooihaa- > nthumuluru=osi-tech.com@lists.php.net > 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- > tech.com@lists.php.net>; Wed, 12 May 2004 15:28:11 +0530 From: > "Nagendra Prasad" <nthumuluru@osi-tech.com> To: php-general- > sc.1084355448.dihjfmikeehgilooihaa-nthumuluru=osi-tech.com@lists.php.net > Reply-To: nthumuluru@osi-tech.com > Subject: Re: confirm subscribe to php-general@lists.php.net > Date: Wed, 12 May 2004 15:28:11 +0530 > Message-Id: <20040512095758.M46317@osi-tech.com> > In-Reply-To: <1084355448.59791.ezmlm@lists.php.net> > References: <1084355448.59791.ezmlm@lists.php.net> > 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: php-general-help@lists.php.net > To: nthumuluru@osi-tech.com > Sent: 12 May 2004 09:50:48 -0000 > Subject: confirm subscribe to php-general@lists.php.net > > > Hi! This is the ezmlm program. I'm managing the > > php-general@lists.php.net mailing list. > > > > I'm working for my owner, who can be reached > > at php-general-owner@lists.php.net. > > > > To confirm that you would like > > > > nthumuluru@osi-tech.com > > > > added to the php-general mailing list, please send > > an empty reply to this address: > > > > php-general-sc.1084355448.dihjfmikeehgilooihaa-nthumuluru=osi- > tech.com@lists.php.net > > > > 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- > > nthumuluru=osi-tech.com@lists.php.net > > > > 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- > > general-request@lists.php.net> 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: > > <php-general-help@lists.php.net> > > > > To subscribe to the list, send a message to: > > <php-general-subscribe@lists.php.net> > > > > 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: > > <php-general-unsubscribe@lists.php.net> > > > > or for the digest to: > > <php-general-digest-unsubscribe@lists.php.net> > > > > 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: > > > > <php-general-owner@lists.php.net> > > > > 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: <root@rn2.php.net> > > > > Received: (qmail 59778 invoked by uid 1010); 12 May 2004 09:50:48 -0000 > > Delivered-To: ezmlm-scan-php-general-subscribe-nthumuluru=osi- > tech.com@lists.php.net > > Delivered-To: ezmlm-php-general-subscribe-nthumuluru=osi- > tech.com@lists.php.net > > > > 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: > <20040512094850.22221.qmail@rn2.php.net> > > To: php-general-subscribe-nthumuluru=osi-tech.com@lists.php.net > > Subject: PHP Mailing List Website Subscription > > From: nthumuluru@osi-tech.com > > > > 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 -------

« previous php.general (#185961) next »