[ic] posttourl.tag

Grant listbox at email.com
Fri Aug 29 16:01:12 EDT 2003


*snip*
> Both HTTP::Headers and HTTP::Request have very good manual pages, and
> the changes to your code will be very simple.
*snip*

After checking out the man pages on HTTP::Headers, I changed the "-"
characters in my headers to "_" and after another minor change, IC restarts
with the tag without any errors.  I feel like I'm close to a successful
POST.  I set up a test page to call the posttourl.tag and got a 500 error.
I noticed the following in my error.log:


[29/August/2003:10:18:24 -0700] path/test.html Runtime error: Can't locate
object method "X_API_COMPATIBILITY_LEVEL" via package "HTTP::Headers" at
/usr/lib/perl5/site_perl/5.6.0/HTTP/Message.pm line 189.


Can anyone interpret that error and point me in the right direction as far
as fixing it?  I'm calling posttourl.tag with the following code:


[perl]
	# params are passed to posttourl via cgi to allow
	# fixed string with variable values
        my $page="";
        $CGI->{url}="https://the.url";
	$CGI->{params}="<?xml version='1.0' encoding='iso-8859-1'?><request>a bunch
of XML</request>";
        $CGI->{apicall}="thecall";
        $page.="Connecting to ".$CGI->{url}
	."?".$CGI->{params}."<br>\n";

        $CGI->{C016}="";
        return $page;
[/perl]
[seti postonly]
[posttourl url="[cgi url]" params="[cgi params]" apicall="[cgi apicall]"]
[/seti]


and here's the posttourl.tag:


Usertag posttourl Order url params apicall
Usertag posttourl Routine <<EOR
use HTTP::Request;
use HTTP::Headers;
use LWP::UserAgent;
sub {
	my ($url,$params,$apicall) = @_;

	local($ENV{'HTTPS_VERSION'}) = '3';
	local($ENV{'HTTPS_CERT_FILE'}) = 'xxx.pem';
	local($ENV{'HTTPS_KEY_FILE'}) = 'xxx.key';

	my $request = new HTTP::Request('POST' => $url);
        $request->content_type('application/x-www-form-urlencoded');
        $request->content($params);
        $request->content_length(length($params));
        $request->X_API_COMPATIBILITY_LEVEL(305);
        $request->X_API_SESSION_CERTIFICATE('sensitive');
        $request->X_API_DEV_NAME('sensitive');
        $request->X_API_APP_NAME('sensitive');
        $request->X_API_CERT_NAME('sensitive');
        $request->X_API_CALL_NAME($apicall);
        $request->X_API_SITEID(0);
        $request->X_API_DETAIL_LEVEL(0);

    	my $ua = new LWP::UserAgent;
    	my $response = $ua->request($request);

    	my $page = $response->as_string() . "\n\n\n";
    	$page .= $response->code() . "\n";
    	$page .= $response->message() . "\n";

    	return $page;
}
EOR


- Grant



More information about the interchange-users mailing list