rzekanet / service-akismet
访问 Akismet API 的小型库
v1.1.1
2014-02-21 18:35 UTC
Requires
- php: >=5.3.0
Suggests
- ext_curl: *
This package is not auto-updated.
Last update: 2024-09-24 07:06:55 UTC
README
访问 Akismet API 的小型库
使用方法
初始化类
$connector = new Riv\Service\Akismet\Connector\Curl();
$akismet = new Riv\Service\Akismet\Akismet($connector);
在初始化过程中,类不再验证 API 密钥。您必须使用 $akismet->keyCheck()
来判断它是否有效。您需要检查 $akismet->getError()
以查看是否存在任何错误
检查 API 密钥
$akismet->keyCheck('api key', 'blog url');
检查评论是否为垃圾邮件
$akismet->check(array(
'permalink' => 'The permanent location of the entry the comment was submitted to',
'comment_type' => 'May be blank, comment, trackback, pingback, or a made up value like "registration"',
'comment_author' => 'Name submitted with the comment',
'comment_author_email' => 'Email address submitted with the comment',
'comment_author_url' => 'URL submitted with comment',
'comment_content' => 'The content that was submitted'
));
上述函数如果评论是垃圾邮件则返回 true
,否则返回 false
。$akismet->sendSpam()
和 $akismet->sendHam()
以相同的方式工作。