Thread OO-Vererbung für Plugins
(49 answers)
Opened by marky at 2012-11-27 11:08
Wo ich gerade dranbin, also textorientierte Schnittstellen sind auch ok, wenn es kleine Datenmengen sind.
Beispiel gefällig (sag: Ja *G*)? Code (perl): (dl
)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 package PayPalNVP; # Name Value Pair API use strict; use warnings; use LWP::UserAgent; use HTTP::Request::Common qw(POST); use CGI; use Data::Dumper; sub new{ my $class = shift; my %in = ( USER => 'sdk-three_api1.sdk.com', PWD => 'QFZCWN5HZM8VBG7Q', VERSION => '2.3', SIGNATURE => 'A-IzJhZZjhg29XQ2qnhapuwxIDzyAZQ92FRP5dqBzVesOkzbdUONzmOU', URL => 'https://api-3t.sandbox.paypal.com/nvp', @_ ); my $self = bless{}, $class; return eval{ $self->{BASE} = \%in; $self->{UA} = LWP::UserAgent->new; $self; }; } sub test{ my $self = shift; my $req = POST $self->{BASE}{URL}, Content => [ USER => $self->{BASE}{USER}, PWD => $self->{BASE}{PWD}, VERSION => $self->{BASE}{VERSION}, SIGNATURE => $self->{BASE}{SIGNATURE}, METHOD => 'SetExpressCheckout', AMT => '10.00', CURRENCYCODE => 'EUR', RETURNURL => 'http://example.com', CANCELURL => 'http://example.com', ]; my $res = $self->{UA}->request($req); # res = Response my $query = CGI->new($res->content); # parse name value pairs my %h = map{ $_ => $query->param($_) }$query->param; print Dumper \%h; } 1;################################################################################################## package main; use strict; use warnings; my $ppa = PayPalNVP->new or die $@; $ppa->test; Kaum zu glauben, der Bot antwortet: Code: (dl
)
1 $VAR1 = { Wenn ich diese NVP-Schnittstelle entwickelt hätte, ich hätt's auch nicht anders gemacht ;) Viele Grüße, Rosti Achja, PS: Die Beispielcodes für Java, ColdFusion, PHP und ASP habe ich mir NICHT angeguckt. Aus Protest, weil in der pdf-Datei Perl nicht mit einem Wort erwähnt ist!!! Last edited: 2012-12-03 19:47:20 +0100 (CET) |