[ic] HTTP POSTing to another server from IC
John Rennie
john.rennie at thechampagneshop.co.uk
Thu Aug 21 20:48:25 EDT 2003
> [big snip]
>
> ... I'm trying to get posttourl.tag set
> up and it looks good to me but IC spits out an error after
> restarting with the tag in the UserTag folder. The error
> looks like this:
>
> Calling UI...UserTag 'posttourl' code is not a subroutine
> reference In line 34 of the configuration file
> '/trippystore/ic493/code/UserTag/posttourl.tag':
>
> Here's the tag modified for my purposes:
>
> Usertag posttourl Order url params apicall
> Usertag posttourl Interpolate 1
> Usertag posttourl Routine <<EOR
> sub {
> require HTTP::Request;
> require HTTP::Headers;
> require LWP::UserAgent; # SSL cabable if Crypt::SSLeay installed
> my $url=shift; my $params=shift;
> $ENV{'HTTPS_VERSION'} = '3';
> $ENV{'HTTPS_CERT_FILE'}='xxx.pem';
> $ENV{'HTTPS_KEY_FILE'}='xxx.key';
>
> my $page="";
> my $request=new HTTP::Request 'POST' => $url;
> $request->Content-Type('text/xml');
> $request->Content($params);
> $request->Content-Length(length($params));
> $request->X-API-COMPATIBILITY-LEVEL(305);
The following lines all have 'confused' quotes and brackets...
> $request->X-API-SESSION-CERTIFICATE' => 'staticinfo');
> $request->X-API-DEV-NAME' => 'staticinfo');
> $request->X-API-APP-NAME' => 'staticinfo');
> $request->X-API-CERT-NAME' => 'staticinfo');
> $request->X-API-CALL-NAME' => '$apicall');
> $request->X-API-SITEID' => '0');
> $request->X-API-DETAIL-LEVEL' => '0');
>
> my $ua=LWP::UserAgent->new;
> my $response = $ua->request($request);
> $page.=$response->as_string,"\n\n\n";
> $page.=$response->code,"\n";
> $page.=$response->message,"\n";
> return $page;
> }
> EOR
>
How about running your sub through perl to check the syntax
(perl -cw perl_script, for example) before trying to get Interchange
to cope with it? :)
Good luck,
John
More information about the interchange-users
mailing list