<<EOR
use HTTP::Request::Common;
use LWP::UserAgent;
sub {
my ($uri,$f,$h,$timeout,$useragent) = @_;
die q{No URI provided to the "post-external" UserTag} unless $uri;
$timeout ¦¦= 30;
$useragent ¦¦= 'post-external';
my %headers = ();
foreach (split(/[\r\n]+/,$h)) {
/^\s*(.+?)\s*[=:]\s*(.*?)\s*$/;
$headers{$1} = $2 if (length($1) && length($2));
}
my %form = ();
foreach (split(/[\r\n]+/,$f)) {
/^\s*(.+?)\s*[=:]\s*(.*?)\s*$/;
$form{$1} = $2 if (length($1) && length($2));
}
my $ua = new LWP::UserAgent(
timeout => $timeout,
agent => $useragent,
);
my $res = $ua->request(POST($uri,\%form,%headers));
die $res->message() unless $res->is_success();
return $res->as_string();
}
EOR
and I'm calling that usertag on a test page with the following code:
[post-external
form=¦
request=<?xml version='1.0' encoding='iso-8859-1'?>
<request xmlns="urn:eBayAPIschema"><RequestUserId>testuser</RequestUserId>
<RequestPassword>testpassword</RequestPassword><DetailLevel>0</DetailLevel><ErrorLevel>1</ErrorLevel>
<SiteId>0</SiteId><Verb>GeteBayOfficialTime</Verb></request>
¦
headers=¦
X-EBAY-API-COMPATIBILITY-LEVEL: 305
X-EBAY-API-SESSION-CERTIFICATE: certificate
X-EBAY-API-DEV-NAME: devname
X-EBAY-API-APP-NAME: appname
X-EBAY-API-CERT-NAME: certname
X-EBAY-API-CALL-NAME: GeteBayOfficialTime
X-EBAY-API-SITEID: 0
X-EBAY-API-DETAIL-LEVEL: 0
Content-Type: text/xml
Content-Length: length($request)
¦
uri=https://api.sandbox.ebay.com/ws/api.dll
timeout=30
]
I know you guys can't comment on anything but the Perl syntax/functionality, but that's OK, I think that must be where the problem lies. I'd REALLY appreciate any help you guys can lend on this one. I've been working on this for a while now.
[edited by: jatar_k at 6:13 pm (utc) on Sep. 13, 2003]
[edit reason] broke line for sidescroll [/edit]