GithubHelp home page GithubHelp logo

mollomjava's Introduction

MollomJava

A Java client library for Mollom, using the RESTful API as described on http://mollom.com/api

Library API

The library API was inherited from the initial XMLRPC client library. For the 1.0 version, we will try to keep this API as stable as possible. As an annoying side effect, there are some conversions between different objects for the same data. For example the CheckContentResponse response class is inherited and the Content and ContentResponse classes map directly to the REST API. We thus have to convert the Content object to a CheckContentResponse object.

The 2.0 version will incorporate a library API that maps more directly to the REST API.

The most important class is the MollomClient class. It contains the functions to check content and captcha's, and send feedback to Mollom. The MollomBlacklist class contains functionality to manipulate your per-site blacklist.

Note: When you determine the IP address of the author, please verify that you're using the right IP. Some reverse proxies put their own IP in the REMOTE_ADDR header and the real IP in HTTP_X_FORWARDED_FOR or HTTP_X_CLUSTER_CLIENT_IP. For more information, see http://mollom.com/api/handling-author-ip-addresses

// create a new mollom client
MollomClient client = new MollomClient("public_key", "private_key");

// create a new request object
CheckContentRequest request = new CheckContentRequest();
request.authorName = "Thomas Meire";
request.postTitle = "Hello";
// TODO: add more fields...

CheckContentResponse contentResponse = client.checkContent(content);
if (contentResponse.isUnsure()) {
    GetCaptchaResponse captchaResponse = client.getImageCaptcha(contentResponse.session_id);
} else if (contentResponse.isHam()) {
    // store the post in the database
} else if (contentResponse.isSpam()) {
    // show a nice message to the user to explain the situation
}

// show the captcha to the user & get the response
String captchaSolution = "....";

boolean correct = client.checkCaptcha(captchaResponse.session_id, captchaSolution, "145.121.126.2");
if (correct) {
  // store the post in the database
} else {
  // retrieve a new captcha & show it again
}

Sub-API status

  • Supported:
  • Content API
  • Captcha API
  • Feedback API
  • Blacklist API
  • In-progress:
  • Whitelist API
  • Unsupported:
  • Site API

mollomjava's People

Contributors

blackskad avatar

Watchers

James Cloos avatar Jack Gould avatar

Forkers

vort1 karlchan-cn

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.