Class Akismet

Description

The Akismet PHP5 Class

This class takes the functionality from the Akismet WordPress plugin written by Matt Mullenweg and allows it to be integrated into any PHP5 application or website.

The original plugin is available on the Akismet website.

Usage:

  1.     $akismet new Akismet('http://www.example.com/blog/''aoeu1aoue');
  2.     $akismet->setCommentAuthor($name);
  3.     $akismet->setCommentAuthorEmail($email);
  4.     $akismet->setCommentAuthorURL($url);
  5.     $akismet->setCommentContent($comment);
  6.     $akismet->setPermalink('http://www.example.com/blog/alex/someurl/');
  7.     if($akismet->isCommentSpam())
  8.       // store the comment but mark it as spam (in case of a mis-diagnosis)
  9.     else
  10.       // store the comment normally

Optionally you may wish to check if your WordPress API key is valid as in the example below.

  1.    $akismet new Akismet('http://www.example.com/blog/''aoeu1aoue');
  2.  
  3.    if($akismet->isKeyValid()) {
  4.      // api key is okay
  5.    else {
  6.      // api key is invalid
  7.    }

Located in /Akismet.class.php (line 64)


	
			
Method Summary
Akismet __construct (string $blogURL, string $wordPressAPIKey)
bool isCommentSpam ()
bool isKeyValid ()
void setAkismetServer ( $akismetServer)
void setAkismetVersion ( $akismetVersion)
void setAPIPort ( $apiPort)
void setCommentAuthor ( $commentAuthor)
void setCommentAuthorEmail ( $authorEmail)
void setCommentAuthorURL ( $authorURL)
void setCommentContent ( $commentBody)
void setCommentType ( $commentType)
void setPermalink (string $permalink)
void setReferrer (string $referrer)
void setUserIP (string $userip)
void submitHam ()
void submitSpam ()
Methods
Constructor __construct (line 92)
  • access: public
Akismet __construct (string $blogURL, string $wordPressAPIKey)
  • string $blogURL: The URL of your blog.
  • string $wordPressAPIKey: WordPress API key.
isCommentSpam (line 180)

Tests for spam.

Uses the web service provided by Akismet to see whether or not the submitted comment is spam. Returns a boolean value.

  • return: True if the comment is spam, false if not
  • throws: Will throw an exception if the API key passed to the constructor is invalid.
  • access: public
bool isCommentSpam ()
isKeyValid (line 127)

Makes a request to the Akismet service to see if the API key passed to the constructor is valid.

Use this method if you suspect your API key is invalid.

  • return: True is if the key is valid, false if not.
  • access: public
bool isKeyValid ()
setAkismetServer (line 284)

Defaults to rest.akismet.com

  • access: public
void setAkismetServer ( $akismetServer)
  • $akismetServer
setAkismetVersion (line 291)

Defaults to '1.1'

  • access: public
void setAkismetVersion ( $akismetVersion)
  • $akismetVersion
setAPIPort (line 277)

Defaults to 80

  • access: public
void setAPIPort ( $apiPort)
  • $apiPort
setCommentAuthor (line 247)

The name that the author submitted with the comment.

  • access: public
void setCommentAuthor ( $commentAuthor)
  • $commentAuthor
setCommentAuthorEmail (line 256)

The email address that the author submitted with the comment.

The address is assumed to be valid.

  • access: public
void setCommentAuthorEmail ( $authorEmail)
  • $authorEmail
setCommentAuthorURL (line 263)

The URL that the author submitted with the comment.

  • access: public
void setCommentAuthorURL ( $authorURL)
  • $authorURL
setCommentContent (line 270)

The comment's body text.

  • access: public
void setCommentContent ( $commentBody)
  • $commentBody
setCommentType (line 240)

The type of comment being submitted.

May be blank, comment, trackback, pingback, or a made up value like "registration" or "wiki".

  • access: public
void setCommentType ( $commentType)
  • $commentType
setPermalink (line 231)

A permanent URL referencing the blog post the comment was submitted to.

  • access: public
void setPermalink (string $permalink)
  • string $permalink: The URL. Optional.
setReferrer (line 222)

To override the referring page when submitting spam/ham later on

  • access: public
void setReferrer (string $referrer)
  • string $referrer: The referring page. Optional.
setUserIP (line 213)

To override the user IP address when submitting spam/ham later on

  • access: public
void setUserIP (string $userip)
  • string $userip: An IP address. Optional.
submitHam (line 204)

Submit ham that is incorrectly tagged as spam.

Using this function will make you a good citizen as it helps Akismet to learn from its mistakes. This will improve the service for everybody.

  • access: public
void submitHam ()
submitSpam (line 195)

Submit spam that is incorrectly tagged as ham.

Using this function will make you a good citizen as it helps Akismet to learn from its mistakes. This will improve the service for everybody.

  • access: public
void submitSpam ()

Documentation generated on Sat, 23 Feb 2008 11:03:15 +0000 by phpDocumentor 1.4.1