matthewbdaly / akismet-client
Akismet PHP客户端
0.1.0
2018-01-09 23:14 UTC
Requires
- php-http/client-implementation: ^1.0
- php-http/discovery: ^1.0
- php-http/httplug: ^1.0
- php-http/message-factory: ^1.0
- psr/http-message: ^1.0
Requires (Dev)
- guzzlehttp/psr7: ^1.0
- php-http/message: ^1.0
- php-http/mock-client: ^1.0
- phpspec/phpspec: ^3.2
- psy/psysh: ^0.8.0
- squizlabs/php_codesniffer: ^2.7
This package is auto-updated.
Last update: 2024-08-28 07:17:06 UTC
README
这是一个用于Akismet垃圾邮件检测服务的PHP客户端。使用现代实践构建,并具有广泛的测试套件。
安装
使用以下命令安装:
composer require matthewbdaly/akismet-client
此库使用HTTPlug,因此您还需要安装一个客户端实现 如此处所述 以实际使用此客户端。
使用方法
客户端提供以下方法
setKey($key)
- 设置API密钥getKey()
- 获取API密钥setBlog($blog)
- 设置博客URLgetBlog()
- 获取博客URLsetIp($ip)
- 设置用户IP地址getIp()
- 获取用户IP地址setAgent($agent)
- 设置用户代理字符串getAgent()
- 获取用户代理字符串setReferrer($referrer)
- 设置引用URLgetReferrer()
- 获取引用URLsetPermalink($permalink)
- 设置文章的永久链接getPermalink()
- 获取文章的永久链接setCommentType($type)
- 设置评论类型 - 可以是comment
、forum-post
、reply
、blog-post
、contact-form
、signup
、message
或自定义类型getCommentType()
- 获取评论类型setCommentAuthor($author)
- 设置评论作者getCommentAuthor()
- 获取评论作者setCommentAuthorEmail($email)
- 设置评论作者电子邮件getCommentAuthorEmail()
- 获取评论作者电子邮件setCommentAuthorUrl($url)
- 设置评论作者URLgetCommentAuthorUrl()
- 获取评论作者URLsetCommentContent($content)
- 设置评论内容getCommentContent()
- 获取评论内容setCommentDateGMT($date)
- 设置评论日期getCommentDate()
- 获取评论日期setCommentPostModifiedDate($date)
- 设置评论修改日期getCommentPostModifiedDate()
- 获取评论修改日期setBlogLang($lang)
- 设置博客语言getBlogLang()
- 获取博客语言setBlogCharset($charset)
- 设置博客字符集getBlogCharset()
- 获取博客字符集setUserRole($role)
- 设置用户角色getUserRole()
- 获取用户角色setIsTest($test)
- 设置是否为测试getIsTest()
- 获取是否为测试flush()
- 清除所有现有值verifyKey()
- 验证当前设置的API密钥check()
- 检查当前设置的评论是否为垃圾邮件spam()
- 将评论提交给Akismet作为垃圾邮件ham()
- 将评论提交给Akismet作为正常邮件setParams(array $params)
- 批量设置参数
所有 set()
方法以及 flush()
方法都是可链式的,因此您可以进行如下操作
$client->setParams($params)
->setCommentType('comment')
->setCommentAuthor('Bob Smith')
->check();
请注意,verifyKey()
、check()
、ham()
和 spam()
不会清除参数,因此请在开始新请求之前确保这样做。