Link | gapi_search |
Author | Kyle Jessup |
Category | Utility |
Version | 8.x |
License | Public Domain |
Posted | 27 Apr 2006 |
Updated | 27 Apr 2006 |
More by this author... |
This tag sends a query to Google via their Search API and parses the results. Requires a valid Google API Key. The sample code below demonstrates how the tag could be used to search the contents of a specific site. For more information about what parameters can be supplied to the tag, and how to use the results, see <http://www.google.com/apis/reference.html#1_1>.
if(action_param('kwd')); // set defaults specific to this site var( 'gapi_site' = 'www.example.com', 'gapi_kwd' = action_param('kwd'), 'gapi_max' = 10, 'gapi_key' = 'a valid Google API key' ); // set skip value if(action_param('skip')); var('gapi_start') = integer(action_param('skip')); else; var('gapi_start' = 0); /if; // retrieve the results protect; local('result' = gapi_search( -q=($gapi_kwd + ' site:' + $gapi_site), -start=$gapi_start, -key=$gapi_key, -maxResults=$gapi_max )); var('gapi_found') = integer(#result->estimatedTotalResultsCount); if($gapi_start + $gapi_max < $gapi_found); var('gapi_shown' = $gapi_start + $gapi_max); else; var('gapi_shown' = $gapi_found); /if; 'Displaying results ' + ($gapi_start + 1) + ' through ' + $gapi_shown + ' of ' + $gapi_found + ' for "' + $gapi_kwd + '."
\n
\n'; iterate(#result->resultElements, local('i')); ' ' + #i->title + '
' + #i->snippet + '
'; /iterate; ''; if($gapi_start > 0); 'Previous'; /if; ' '; if($gapi_start + $gapi_max < $gapi_found); 'Next'; /if; '\n'; handle_error; 'Oops! We had trouble interpreting the response from Google. Please try again.
'; /handle_error; /protect; /if;
Click the "Download" button below to retrieve a copy of this tag, including the complete documentation and sample usage shown on this page. Place the downloaded ".inc" file in your LassoStartup folder, restart Lasso, and you can begin using this tag immediately.
soap_definetag( 'search', -namespace='gapi_', -wsdl=xml(include_url('http://api.google.com/GoogleSearch.wsdl')), -operationname='doGoogleSearch', -defaults=map( 'filter'=false, 'restrict'='', 'safeSearch'=false, 'lr'='', 'ie'='', 'oe'='' ), -procs=array( proc_extractOne('*[1]/*[1]'), \proc_convert ) );
©LassoSoft Inc 2015 | Web Development by Treefrog Inc | Privacy | Legal terms and Shipping | Contact LassoSoft
Error on startup