devfactory/mollom

Mollom for laravel 4

2.0.0 2015-07-09 15:23 UTC

This package is auto-updated.

Last update: 2024-11-16 03:57:55 UTC


README

Mollom for laravel 4.2

Build Status Code Climate Scrutinizer Code Quality Test Coverage Latest Stable Version Total Downloads License

##How to setup

update composer.json file:

{
    "require": {
        "devfactory/mollom": "1.0.5"
    }
}

and run composer update from terminal to download files.

update app.php file in app/config directory:

'providers' => array(
  'Devfactory\Mollom\MollomServiceProvider',
),
alias => array(
    'Mollom'          => 'Devfactory\Mollom\Facades\Mollom',
),

##Configuration

 php artisan config:publish devfactory/mollom
<?php

return array(

	/*
	|--------------------------------------------------------------------------
	| Mollom dev Mode
	|--------------------------------------------------------------------------
	|
	| When the dev mode is enabled the package will use the dev.mollom.com api
	|
	*/
    'dev' => false,

	/*
	|--------------------------------------------------------------------------
	| Mollom Public Key
	|--------------------------------------------------------------------------
	|
	| This key is used to comminicate with the mollom api
    | https://mollom.com/user/xxxx/site-manager
	|
	*/
    'mollom_public_key' => '',

	/*
	|--------------------------------------------------------------------------
	| Mollom private Key
	|--------------------------------------------------------------------------
	|
	| This key is used to comminicate with the mollom api
    | https://mollom.com/user/xxxx/site-manager
    |
    */
   'mollom_private_key' => '',

    /*
    | List of ISO 639-1 language codes supported by Mollom.
    |
    | If your application has a predefined list of ISO 639-1 languages already,
    | intersect your list with this via strtok($langcode, '-').
    |
    | example : en
   */
   'mollom_languages_expected' => '',
);

##How to use captcha in your blade add following code:

{{ Mollom::captcha('cpachaID') }}
{{ Form::text('capchaInput') }}

and for validate user entered data just add mollom to array validation rules.

$rules = array(
  'capchaInput' => 'required|mollom:cpachaID'
);

$validator = Validator::make(Input::all(), $rules);

if($validator -> fails()) {
  return Redirect::back() -> withErrors($validator);
}

##How to check the comment spam This method will contact mollom to check a content

    $comment = array(
        'title' => 'comment title',
        'body' => 'body comment',
        'name' => 'authorName',
        'mail' => 'authorEmail'
    );

    try {
      $result = Mollom::comment($comment);

    } catch (\Devfactory\Mollom\Exceptions\UnknownSpamClassificationException $e) {
      //Mollom return anothor value
    } catch (\Devfactory\Mollom\Exceptions\SystemUnavailableException $e) {
      // Unable to contact mollom
    }

And return :

'ham'    //Is not a spam

'spam'   //Is a spam

'unsure' //Not sure you should display a captcha