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

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

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

romano83/akismet

最新稳定版本:1.0

Composer 安装命令:

composer require romano83/akismet

包简介

PSR-7 library to communicate with Akismet service to determine if a submitted comment to your website should be considered spam or not.

README 文档

README

Build Status Latest Stable Version License

A PHP-7 class to communicate with Akismet service to determine if a submitted comment to your website should be considered spam or not.

Installation

Requirements

  • PHP 7.1

Steps to install

Run : composer require romano83/akismet or in your composer.json file

"require": {
    "romano83/akismet" : "^1.0"
}

How to use it

Before to use it, you need an Akismet API key. Once you have one, in order to check if a comment is a spam:

<?php
use Romano83\Akismet;

$website = 'https://your-website.com'; // must be a full URI including http:// or https://
$apikey = 'YOUR_API_KEY';
$akismet = new Akismet($website, $apikey);

$akismet->setCommentAuthor($author)
    ->setCommentAuthorEmail($email)
    ->setCommentContent($comment);
    
if ($akismet->isCommentSpam()) {
    // store the comment and mark it as a spam
} else {
    // store the comment normally
}

It's that simple!

If Akismet filter wrongly tags messages, you can use this following methods :

$akismet->submitSpam();

or

$akismet->submitHam();

to submit mis-diagnosed spam and ham, which improves the system for everybody.

Others methods

This class provides you a set of methods in order to add parameters for comment check or submitted spam and ham. This methods are :

  • setUserIp (required)
  • setUserAgent (required)
  • setReferrer (note spelling)
  • setPermalink
  • setCommentType
  • setCommentAuthor
  • setCommentAuthorEmail
  • setCommentAuthorUrl
  • setCommentContent
  • setCommentDateGmt
  • setCommentPostModifiedGmt
  • setBlogLang
  • setBlogCharset
  • setUserRole
  • setIsTest

All methods return self in order to have a fluent interface.

If you want more details for each method, look at the internal documentation or follow this link.

How to contribute

  • create a ticket in Github if you have found a bug.
  • create a new branch if you want to do a PR.
  • you must add testcases

统计信息

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

GitHub 信息

  • Stars: 8
  • Watchers: 1
  • Forks: 4
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-12-07