A Python 3 Akismet client library.
The Following Akismet API Calls are currently supported:
- Comment Check
- Submit Ham
- Submit Spam
The following Akismet API Calls are not yet supported:
- Key Verification
-
Signup for Akismet and get yourself an API key at http://akismet.com/plans/
-
Install this library:
pip install pykismet3
-
Make some calls to Akismet (see example below to get started)
Import and instantiate Pykismet.
from pykismet3 import Akismet
import os
a = Akismet(blog_url="http://your.blog/url",
user_agent="My Awesome Web App/0.0.1")
a.api_key="YOUR_AKISMET_API_KEY"
a.check({'user_ip': os.environ['REMOTE_ADDR'],
'user_agent': os.environ['HTTP_USER_AGENT'],
'referrer': os.environ.get('HTTP_REFERER', 'unknown'),
'comment_content': 'I LIEK YOUR WEB SITE',
'comment_author': 'Comment Author',
'is_test': 1,
})
a.submit_ham({'user_ip': os.environ['REMOTE_ADDR'],
'user_agent': os.environ['HTTP_USER_AGENT'],
'referrer': os.environ.get('HTTP_REFERER', 'unknown'),
'comment_content': 'I LIEK YOUR WEB SITE',
'comment_author': 'Comment Author',
'is_test': 1,
})
a.submit_spam({'user_ip': os.environ['REMOTE_ADDR'],
'user_agent': os.environ['HTTP_USER_AGENT'],
'referrer': os.environ.get('HTTP_REFERER', 'unknown'),
'comment_content': 'I LIEK YOUR WEB SITE',
'comment_author': 'Comment Author',
'is_test': 1,
})
The examples above show you pretty much everything you need to know.
For a full list of supported parameters for each API call, see http://akismet.com/development/api/
The code is only ~150 lines long anyway, so just look at '''pykismet.py''' if you aren't sure about something.
Patches to fix bugs and implement missing features welcome! Please make a pull request.