openclassrooms/akismet 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

openclassrooms/akismet

最新稳定版本:v3.0.0

Composer 安装命令:

composer require openclassrooms/akismet

包简介

Akismet Library

README 文档

README

SensioLabsInsight Build Status Coverage Status

This is a PHP5 library that provides Akismet Spam Protection service functionality in your application.

Installation

The easiest way to install Akismet Library is via composer.

Create the following composer.json file and run the php composer.phar install command to install it.

{
    "require": {
        "openclassrooms/akismet": "*"
    }
}
<?php
require 'vendor/autoload.php';

use OpenClassrooms\Akismet\Services\AkismetService;

//do things

Basic Usage

The AkismetServiceImpl class needs to set a client to communicate with Akismet Spam Protection service. This library provides a client based on GuzzleHttp\Client, though you can implement your own client. Then, you can set the client using the AkismetServiceImpl::setClient() method.

The Models

Comment

This Library defines a "Comment" interface which must be passed as an argument into the different AkismetService methods.

use OpenClassrooms\Akismet\Models\Comment;

$comment = new CommentImpl();

Comment Builder

This library provides a Builder to create the Comment:

use OpenClassrooms\Akismet\Models\CommentBuilder;

$comment = $commentBuilder->create()
                          ->withUserIp(CommentStub::USER_IP)
                          ->withUserAgent(CommentStub::USER_AGENT)
                          ->withReferrer(CommentStub::REFERRER)
                          ->withPermalink(CommentStub::PERMALINK)
                          ->withAuthorName(CommentStub::AUTHOR_NAME)
                          ->withAuthorEmail(CommentStub::AUTHOR_EMAIL)
                          ->withContent(CommentStub::CONTENT)
                          ->build();

Service

Use OpenClassrooms\Akismet\Services\Impl\AkismetServiceImpl;

$akismetService = new AkismetServiceImpl();

// commentCheck method needs only one parameter, which has to be the Comment object
if ($akismetService->commentCheck($comment)) {
 // store the comment and mark it as spam (in case of a misdiagnosis).
} else {
 // store the comment normally
}

to submit misdiagnosed spam and ham, which improves the system for everybody.

$akismetService->submitSpam($comment);

And

$akismetService->submitHam($comment);

Beyond this Library

If you plan to use Akismet Library in a Symfony2 project, check out the AkismetBundle. The bundle provides an easy configuration option for this library.

统计信息

  • 总下载量: 466.18k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 3
  • 点击次数: 1
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 3
  • Watchers: 25
  • Forks: 3
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-06-10