Lasso Soft Inc. > Home

[akismet]

Linkakismet
AuthorJason Huck
CategoryUtility
Version7.x
Licensehttp://opensource.org/licenses/artistic-license.php
Posted27 Apr 2006
Updated28 Apr 2006
More by this author...

Description

This set of tags implements the Akismet API in Lasso. Akismet is a web service that allows you to check user-contributed content, such as comments on a blog entry, for spam. See the online documentation and example code below for usage instructions. Requires a valid WordPress API Key.

Sample Usage

var('authtest') = akismet_auth( -key=$key, -blog=server_name);

'Auth Test: ' + $authtest + '
\n'; var('commentchecktest') = akismet_commentcheck( -key=$key, -blog=server_name, -user_ip=nslookup('www.omnipilot.com'), -user_agent=client_browser, -comment_content='viagra-test-123' ); 'Comment Check: ' + $commentchecktest + '
\n';

Source Code

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.

> 'valid';
			return: true;
		else;
			return: false;
		/if;
	/define_tag;


	define_tag: 
		'akismet_commentcheck',
		-required='key',
		-required='blog',
		-required='user_ip',
		-required='user_agent',
		-optional='referrer',
		-optional='permalink',
		-optional='comment_type',
		-optional='comment_author',
		-optional='comment_author_email',
		-optional='comment_author_url',
		-optional='comment_content';
		
		local: 'postparams' = array;
		
		iterate: params, local: 'i';
			if: #i->first != '-key';
				local: 'name' = #i->first;
				#name->(removeleading: '-');
				#postparams->(insert: #name = #i->second);
			/if;
		/iterate;
		
		local: 'result' = (include_url:
			'http://' + #key + '.rest.akismet.com/1.1/comment-check',
			-postparams = #postparams
		);
		
		if: #result >> 'true';
			return: true;
		else;
			return: false;
		/if;
	/define_tag;
	
	
	define_tag: 
		'akismet_submitspam',
		-required='key',
		-required='blog',
		-required='user_ip',
		-required='user_agent',
		-optional='referrer',
		-optional='permalink',
		-optional='comment_type',
		-optional='comment_author',
		-optional='comment_author_email',
		-optional='comment_author_url',
		-optional='comment_content';
		
		local: 'postparams' = array;
		
		iterate: params, local: 'i';
			if: #i->first != '-key';
				local: 'name' = #i->first;
				#name->(removeleading: '-');
				#postparams->(insert: #name = #i->second);
			/if;
		/iterate;
		
		local: 'result' = (include_url:
			'http://' + #key + '.rest.akismet.com/1.1/submit-spam',
			-postparams = #postparams
		);		
	/define_tag;


	define_tag: 
		'akismet_submitham',
		-required='key',
		-required='blog',
		-required='user_ip',
		-required='user_agent',
		-optional='referrer',
		-optional='permalink',
		-optional='comment_type',
		-optional='comment_author',
		-optional='comment_author_email',
		-optional='comment_author_url',
		-optional='comment_content';
		
		local: 'postparams' = array;
		
		iterate: params, local: 'i';
			if: #i->first != '-key';
				local: 'name' = #i->first;
				#name->(removeleading: '-');
				#postparams->(insert: #name = #i->second);
			/if;
		/iterate;
		
		local: 'result' = (include_url:
			'http://' + #key + '.rest.akismet.com/1.1/submit-ham',
			-postparams = #postparams
		);		
	/define_tag;
//]
?>

Comments

02 Apr 2008, Jeff Payanis

Minor change

I believe line 13 should be a == instead of >>. If I pass in a made up API key, they pass back a response of "invalid", which contains the word "valid".

Please log in to comment

Subscribe to the LassoTalk mail list

LassoSoft Inc. > Home

 

 

©LassoSoft Inc 2015 | Web Development by Treefrog Inc | PrivacyLegal terms and Shipping | Contact LassoSoft