default
[ class tree: default ] [ index: default ] [ all elements ]

Class: Akismet

Source Location: /Akismet.php

Class Overview


Codeigniter Askimet


Author(s):

Version:

  • 1.0

Constants

Methods



Class Details

[line 80]
Codeigniter Askimet

You will need an API key to be able to use this library. You can get an API from The Akismet website

To install, place this file in the application/libraries directory.

To set up a default API key and blog URL to use put the following in the application config.php file:

  1.  $config['akismet_api_key']  '<your key here>';
  2.  $config['akismet_blog_url''http://www.example.com/';

Then just change the values to the API key and website URL.

Example usage:

  1.  <?php
  2.  $this->load->library('Akismet');
  3.  
  4.  if($this->akismet->is_key_valid(array('key' => 'API-KEY-HERE')))
  5.      $this->akismet->set_key('API-KEY-HERE');
  6.  
  7.  // the comment to check, see is_spam for full list
  8.  $comment array(
  9.          'comment_author'       => 'Auther',
  10.          'comment_author_email' => 'nobody@example.com',
  11.          'comment_author_url'   => 'http://www.example.com/',
  12.          'comment_content'      => 'This is an example comment.'
  13.      );
  14.  
  15.  // check the comment
  16.  if($this->akismet->is_spam($comment))
  17.      echo 'The comment is spam.';
  18.  
  19.  // mark it as spam
  20.  $this->akismet->mark_spam($comment);
  21.  
  22.  // mark it as ham
  23.  $this->akismet->mark_ham($comment);
  24.  ?>




Tags:

author:  Sam <samclarke.com>
version:  1.0


[ Top ]


Class Methods


constructor __construct [line 105]

Akismet __construct( [ $api_key = null])



Tags:

access:  public


Parameters:

   $api_key  

[ Top ]

method check [line 158]

bool check( array $comment_data)

Alias ofis_spam



Tags:

see:  Akismet::is_spam()
access:  public


Parameters:

array   $comment_data  

[ Top ]

method get_key [line 215]

string get_key( )

Gets the API key currently being used



Tags:

access:  public


[ Top ]

method is_key_valid [line 173]

bool is_key_valid( [ $key_data = array()])

Checks if a key is valid.

$key_data should be in the following format:

  • blog (defaults to site_url('/'))
The front page or home URL of the instance making the request. For a blog or wiki this would be the front page. Note: Must be a full URI, including http://.




Tags:

access:  public


Parameters:

array   $key_data  

[ Top ]

method is_spam [line 144]

bool is_spam( [ $comment_data = array()])

Checks if a comment is spam.

$comment_data should be an assoc array containing the following:

  • blog (defaults to site_url('/'))
The front page or home URL of the instance making the request. For a blog or wiki this would be the front page. Note: Must be a full URI, including http://.
  • user_ip (will try to detect the correct IP if not specified)
IP address of the comment submitter.
  • user_agent (defaults to request user agaent)
User agent string of the web browser submitting the comment - typically the HTTP_USER_AGENT cgi variable. Not to be confused with the user agent of your Akismet library.
  • referrer (defaults to request referer)
The content of the HTTP_REFERER header should be sent here.
  • permalink
The permanent location of the entry the comment was submitted to.
  • comment_type
May be blank, comment, trackback, pingback, or a made up value like "registration".
  • comment_author
Name submitted with the comment
  • comment_author_email
Email address submitted with the comment
  • comment_author_url
URL submitted with comment
  • comment_content
The content that was submitted.




Tags:

return:  True if is spam and false if not
access:  public


Parameters:

array   $comment_data  

[ Top ]

method mark_ham [line 191]

void mark_ham( array $comment_data)

Marks a comment as ham.

Ham is a comment that was marked as spam incorrectly.

$comment_data shoudd be an assoc array containing the comments data. For more information see {@see is_spam}




Tags:

access:  public


Parameters:

array   $comment_data  

[ Top ]

method mark_spam [line 205]

void mark_spam( array $comment_data)

Marks a comment as spam.

$comment_data shoudd be an assoc array containing the comments data. For more information see {@see is_spam}




Tags:

access:  public


Parameters:

array   $comment_data  

[ Top ]

method set_key [line 224]

void set_key( string $key, [ $only_set_if_valid = false], [ $blog_url = null])

Changes the API key used



Tags:

access:  public


Parameters:

string   $key   The new API key
   $only_set_if_valid  
   $blog_url  

[ Top ]


Class Constants

API_URL =  'rest.akismet.com'

[line 90]

Askimet API url


[ Top ]

VERSION =  '1.0'

[line 85]

Askimet Codeigniter library version


[ Top ]



Documentation generated on Thu, 07 Jul 2011 19:50:07 +0100 by phpDocumentor 1.4.3