views:

644

answers:

4

Hi, I need to send an HTTPS request without using LWP::UserAgent or HTTP::request? What is another method of doing so? This is the request I need to send:

POST https://payflowpro.paypal.com/
Connection: close
Host: payflowpro.paypal.com
Content-Length: 181
Content-Type: text/namevalue
X-VPS-CLIENT-TIMEOUT: 30
X-VPS-REQUEST-ID: 1249403513SNOID
X-VPS-VIT-INTEGRATION-PRODUCT: Product
X-VPS-VIT-INTEGRATION-VERSION: 4.0
X-VPS-VIT-OS-NAME: linux
X-VPS-VIT-OS-VERSION: 2.6.16-gentoo-r13
X-VPS-VIT-RUNTIME-VERSION: 5.008007

EXPDATE[4]=1011&AMT[6]=100.01&ACCT[16]=4111111111111111&TENDER[1]=C&TAXAMT[4]=0.00&PARTNER[8]=******&PWD[9]=******&VENDOR[6]=******&USER[6]=******&TRXTYPE[1]=S&VERBOSITY=MEDIUM
+5  A: 

Look up an SSL library and open the socket yourself, then send the data in.

I'd recommend against that though. Much better to do it properly via one of the modules you mentioned by feeding the module the correct parameters so it will do the request you want.

Kristoffon
+7  A: 

Are you looking for README.SSL?

Encryption support is obtained through the use of Crypt::SSLeay or IO::Socket::SSL, which can both be found from CPAN. While libwww-perl has "plug-and-play" support for both of these modules (as of v5.45), the recommended module to use is Crypt::SSLeay.

Sinan Ünür
A: 

I'm not sure it's smart to be giving us your paypal request id and other data... The exact data being sent to the server isn't really relevant here; what matters more is the type of error you are getting when you use LWP::UserAgent. You indicated in a previous question that you were getting HTTP 500 errors, which suggests there is something wrong with the recipient, or you are sending data which is being rejected.

Ether
This data is not real... obviously I wouldn't post that, the problem with LWP::UserAgent turned out to be erroneous SSL packages installed on the server my webpage is hosted on
+1  A: 

Thanks to package reference by Sinan Ünür I was able to accomplish what I needed:

my $host = 'pilot-payflowpro.paypal.com';
my $port = 443;
my $sock = IO::Socket::SSL->new("$host:$port") || die $!;

my $req = 'EXPDATE[4]=1011&AMT[6]=100.01&ACCT[16]=4111111111111111&TENDER[1]=C&TAXAMT[4]=0.00&PARTNER[8]=*****&PWD[9]=******&VENDOR[6]=*****&USER[6]=******&TRXTYPE[1]=S&VERBOSITY=MEDIUM';

print $sock "POST https://$host/ HTTPS/1.1\r\n";
print $sock "Connection: close", "\r\n";
print $sock "Host: ", $host, "\r\n";
print $sock "Content-length: ", length $req, "\r\n";
print $sock "Content-type: text/namevalue\r\n";
print $sock "X-VPS-CLIENT-TIMEOUT: 30", "\r\n";
print $sock "X-VPS-REQUEST-ID: 1249403513SNOID", "\r\n";
print $sock "X-VPS-VIT-INTEGRATION-PRODUCT: Product", "\r\n";
print $sock "X-VPS-VIT-INTEGRATION-VERSION: 4.0", "\r\n";
print $sock "X-VPS-VIT-OS-NAME: linux", "\r\n";
print $sock "X-VPS-VIT-OS-VERSION: 2.6.16-gentoo-r13", "\r\n";
print $sock "X-VPS-VIT-RUNTIME-VERSION: 5.008007", "\r\n\r\n";
print $sock $req, "\r\n\r\n";

print while <$sock>;

close $sock;
But of course, using LWP would have accomplished the same thing, only more easily. (BTW, \r\n is not portable.)There are also a variety of Paypal modules on CPAN. You probably could have saved yourself a ton of time if you had used a library instead of written everything from scratch.
jrockway
No, LWP does not work on my hosting companies web servers with https for some reason which is why I asked the question. the perl modules for my particular problem are not being supported anymore with the new payflow engine coming out next month so I needed this.