Re: Changing perl to PHP

From: Date: Wed, 12 Sep 2001 18:42:40 +0000
Subject: Re: Changing perl to PHP
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-67004@lists.php.net to get a copy of this message
<?php $fp = fsockopen("www.paypal.com", 443, $errono, $errstr, 30); if (!$fp) { echo "$errstr ($errno)<br>\n"; } else { fputs ($fp, "GET https://www.paypal.com/cgi-bin/webscr HTTP/1.1\015\012"); fputs ($fp, "HOST www.paypal.com\015\012"); fputs ($fp, "Content-type: application/x-www-form-urlencoded\015\012"); fputs ($fp, "Content-Length: ". strlen($query)."\015\012"); fputs ($fp, "Connection: Close\015\012"); fputs ($fp, $query); // you might want to do some urlencoding here, if it hasn't been done already.. fputs ($fp, "\015\012\015\012"); while (!feof($fp)) { $return .= fgets ($fp,128); } fclose ($fp); } ?> ----- Original Message ----- From: "Richard Kurth" <rkurth@pacifier.com> To: "php" <php-general@lists.php.net> Sent: Wednesday, September 12, 2001 4:01 PM Subject: [PHP] Changing perl to PHP > Could somebody tell me how to convert this little bet of code to PHP. > The rest of the code for this was easy to do but I dont know what to > do with this. Can I call LWP from php and if yes how? > > # read the post from PayPal system and add 'cmd' > read (STDIN, $query, $ENV{'CONTENT_LENGTH'}); > $query .= '&cmd=_notify-validate'; > > # post back to PayPal system to validate > use LWP::UserAgent; > $ua = new LWP::UserAgent; > $req = new HTTP::Request > 'POST','https://www.paypal.com/cgi-bin/webscr'; > $req->content_type('application/x-www-form-urlencoded'); > $req->content($query); > $res = $ua->request($req); > > > > > > > > > > > > > > Best regards, > Richard > mailto:rkurth@pacifier.com > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net >

« previous php.general (#67004) next »