I am running into a weird problem moving from a plain perl script to putting the code into a mason page when using Google's search API, and need some ideas.
Every time I run the mason page I get $results being undef. When I run the perl script it gives me the 10 results from the query (most of the time, there is some probably with Google's api that makes it not work every time). I don't see any difference between my query to google from the perl script and from the mason page, yet from the mason page it fails every single time. Below is the perl script and the mason code. The perl script looks like this: -------------------------------perl script------------------------------- #!/usr/local/bin/perl use strict; # Location of the GoogleSearch WSDL file. my $google_wdsl = "/pathtofolderwithwsdlfile/GoogleSearch.wsdl"; my $google_key='insertyourapikeyhere'; # Use the SOAP::Lite Perl module. use SOAP::Lite; # Take the query from the command line. my $query = 'something'; # Create a new SOAP::Lite instance, feeding it GoogleSearch.wsdl. my $google_search = SOAP::Lite->service("file:$google_wdsl"); # Query Google. my $results; $results = $google_search -> doGoogleSearch( $google_key, $query, 0, 10, "false", "", "false", "", "latin1", "latin1" ); # No results? if ($results eq undef) { print "No Go Buddy!\n"; } exit unless $results; @{$results->{resultElements}} or exit; # Loop through the results. foreach my $result (@{$results->{resultElements}}) { # Print out the main bits of each result print join "\n", $result->{URL}, $result->{snippet} || 'no snippet', "\n"; } -------------------------------end perl script------------------------------- -------------------------------mason page------------------------------- <%args> $url => 'http://www.somedomain.com' $keyword => 'something' </%args> <%init> my $google_key='insertyourapikeyhere'; my $google_wdsl = "/pathtofolderwithwsdlfile/GoogleSearch.wsdl"; use SOAP::Lite; my $query = $keyword; my $google_search = SOAP::Lite->service("file:$google_wdsl"); my $results; $results = $google_search -> doGoogleSearch( $google_key, $keyword, 0, 10, "false", "", "false", "", "latin1", "latin1" ); if ($results eq undef) { $m->print("No Go Buddy!"); } exit unless $results; @{$results->{resultElements}} or exit; </%init> % # Loop through the results. % foreach my $result (@{$results->{resultElements}}) { % my $url = $result->{URL}; % my $snippet = $result->{snippet} || 'None'; <li> <% $url %> % } -------------------------------end mason page------------------------------- ------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ Mason-users mailing list Mason-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mason-users