Giter Site home page Giter Site logo

python-akismet's Introduction

Latest Tests CI build status Latest PyPI version Python versions Code Climate Test coverage Requirements Status

Python-akismet

Pykismet3 fork. Support older versions of Python and improvements.

Supported API

The Following Akismet API Calls are currently supported:

  • Comment Check
  • Submit Ham
  • Submit Spam

Unsupported API

The following Akismet API Calls are not yet supported: * Key Verification

Installation

  1. Signup for Akismet and get yourself an API key at http://akismet.com/plans/ (You don't need to pay)

  2. Install this library:

    pip install python-akismet
    
  3. Make some calls to Akismet (see example below to get started)

Example

Import and instance Akismet.

from akismet import Akismet

# API KEY (first argument) is required. blog can be defined later.
akismet = Akismet('1ba29d6f120c', blog="http://your.blog/url",
                  application_user_agent="My Application Name/0.0.1")

Comment Check

akismet.check('192.168.1.3', 'Firefox / COMMENT USER AGENT', comment_author='King Arthur',
              comment_author_email='[email protected]', comment_author_url='http://camelot.co.uk',
              comment_content='The Lady of the Lake, her arm clad in the purest shimmering samite, '
                               'held aloft Excalibur from the bosom of the water, signifying by divine'
                               ' providence that I, Arthur, was to carry Excalibur. That is why I '
                               'am your king.', referrer='http://camelot-search/?q=Peasant+Woman')

Submit Ham

akismet.submit_ham('192.168.1.12', 'FIREFOX / COMMENT USER AGENT', comment_author='Tim',
                   comment_author_email='[email protected]',
                   comment_author_url='http://witch.co.uk',
                   comment_content="Look, that rabbit's got a vicious streak a mile wide!"
                                   "It's a killer!")

Submit Spam

akismet.submit_spam('192.168.1.4', 'FIREFOX / COMMENT USER AGENT', comment_author='Frenchman',
                    comment_author_email='[email protected]',
                    comment_author_url='http://guy-de-lombard.fr',
                    comment_content="You don't frighten us, English pig-dogs! Go and boil your "
                                    "bottoms, sons of a silly person! I blow my nose at you, "
                                    "so-called Ah-thoor Keeng, you and all your silly English "
                                    "K-n-n-n-n-n-n-n-niggits!")

Documentation

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 ~100 lines long anyway, so just look at '''akismet''' if you aren't sure about something.

python-akismet's People

Contributors

bellini666 avatar bennythink avatar cfinke avatar fluxflashor avatar grundleborg avatar nekmo avatar nico-b avatar nijel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

python-akismet's Issues

Fails to install with distutils 59.1.0

Description

Installation fails with distutils 59.1.0:

   Traceback (most recent call last):
    File "<string>", line 1, in <module>
    File "/tmp/pip-install-2zi1n0lu/python-akismet_915ecaab43fa40119c0ad12ce5d89261/setup.py", line 280, in <module>
      setup(
    File "/opt/hostedtoolcache/Python/3.9.8/x64/lib/python3.9/site-packages/setuptools/__init__.py", line 153, in setup
      return distutils.core.setup(**attrs)
    File "/opt/hostedtoolcache/Python/3.9.8/x64/lib/python3.9/distutils/core.py", line 148, in setup
      dist.run_commands()
    File "/opt/hostedtoolcache/Python/3.9.8/x64/lib/python3.9/distutils/dist.py", line 966, in run_commands
      self.run_command(cmd)
    File "/opt/hostedtoolcache/Python/3.9.8/x64/lib/python3.9/distutils/dist.py", line 985, in run_command
      cmd_obj.run()
    File "/opt/hostedtoolcache/Python/3.9.8/x64/lib/python3.9/site-packages/setuptools/command/egg_info.py", line 292, in run
      writer(self, ep.name, os.path.join(self.egg_info, ep.name))
    File "/opt/hostedtoolcache/Python/3.9.8/x64/lib/python3.9/site-packages/setuptools/command/egg_info.py", line 656, in write_pkg_info
      metadata.write_pkg_info(cmd.egg_info)
    File "/opt/hostedtoolcache/Python/3.9.8/x64/lib/python3.9/distutils/dist.py", line 1117, in write_pkg_info
      self.write_pkg_file(pkg_info)
    File "/opt/hostedtoolcache/Python/3.9.8/x64/lib/python3.9/site-packages/setuptools/dist.py", line 167, in write_pkg_file
      write_field('Summary', single_line(self.get_description()))
    File "/opt/hostedtoolcache/Python/3.9.8/x64/lib/python3.9/site-packages/setuptools/dist.py", line 151, in single_line
Error:       raise ValueError('Newlines are not allowed')
  ValueError: Newlines are not allowed

This is already fixed in 13e4502, but not yet released to PyPI...

What I Did

pip install python-akismet

See Also

pypa/setuptools#2870

Build issues in pip 10.0

The import from pip.req import parse_requirements is no longer available. This causes the setup.py call to fail on pip 10.0

Since the only requirement is the requests library, it's probably a better idea to include that directly in setup.py: install_requires=['requests']

Getting errors with your example

Hello,

I can't make it work, either with your examples or those provided in Akismet API Documentation.
For every call I make, I get this error in return: 'akismet.exceptions.AkismetServerError: Akismet server returned an error: invalid
A pdb print of the response.json() give me this: 'ValueError: Expecting value: line 1 column 1 (char 0)'

When I do a direct call to the POST API (check method) with these parameters, my request is perfectly valid.

Any hint? Thanks

Submit spam/ham - no return value

.check() seems to work fine (I get back True/False) but submit_spam() and submit_spam() have no return value, so it's unclear whether they worked or not. No errors, just nothing. Should I assume this means the submissions were successful? It would be handy to have a return value to work with, so we could:

if submit_spam(...):
    // Do something

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.