检查自定义表单中的垃圾邮件-Akimet

时间:2013-04-08 作者:tomas

我有一个带有输入表单的插件,我决定用akismet检查提交的数据。我有API密钥,WP注释被正确过滤。。。

以下是我的发现:http://www.binarymoon.co.uk/2010/03/akismet-plugin-theme-stop-spam-dead/

问题是$response 总是空的-我试着var_dump() 就在打电话之后akismet_http_post(), 输出为string(0) ""...

你能告诉我我做错了什么吗?

谢谢

1 个回复
最合适的回答,由SO网友:Ján Bočínec 整理而成

问题是全球global $akismet_api_host, $akismet_api_port; 不是到处都有。我建议在"init" hook...

add_action(\'init\', \'myAkismetInit\');

function myAkismetInit() 
{
    var_dump ( bm_checkSpam(\'\') );
}
查看Akismet API documentation.

另一个选项是使用以下包装类之一:

https://github.com/tijsverkoyen/Akismet

use \\TijsVerkoyen\\Akismet\\Akismet;

// create instance
$akismet = new Akismet(APIKEY, URL);

$response = $akismet->verifyKey();
$response = $akismet->isSpam(\'Nice one. Thanks\', \'Joris\', \'[email protected]\', \'\', null, \'comment\');
$response = $akismet->submitHam(
    \'Great portal! <a href="http://key-west-florida-fishing-charters.6xyotd.us/ " rel="nofollow">Key west florida fishing charters</a><a href="http://kates-playground-videos.6xyotd.us/ " rel="nofollow">Kates playground videos</a><a href="http://karaoke-norah-jones.6xyotd.us/ " rel="nofollow">Karaoke norah jones</a><a href="http://kiera-knightly-naked.6xyotd.us/ " rel="nofollow">Kiera knightly naked</a><a href="http://kelli-fox.6xyotd.us/ " rel="nofollow">Kelli fox</a><a href="http://ky-farm-bureau.6xyotd.us/ " rel="nofollow">Ky farm bureau</a><a href="http://kari-gold.6xyotd.us/ " rel="nofollow">Kari gold</a><a href="http://julie-gibson-diaspora.6xyotd.us/ " rel="nofollow">Julie gibson diaspora</a><a href="http://keely-net.6xyotd.us/ " rel="nofollow">Keely net</a><a href="http://kellie-pickler-tits.6xyotd.us/ " rel="nofollow">Kellie pickler tits</a><a href="http://korean-central-news-agency.6xyotd.us/ " rel="nofollow">Korean central news agency</a><a href="http://kings-quest-3-walkthru.6xyotd.us/ " rel="nofollow">King&#8217;s quest 3 walkthru</a><a href="http://kennels-in-hilton-head.6xyotd.us/ " rel="nofollow">Kennels in hilton head</a><a href="http://kentucky-tv-stations.6xyotd.us/ " rel="nofollow">Kentucky tv stations</a><a href="http://kauffman-foundation.6xyotd.us/ " rel="nofollow">Kauffman foundation</a><a href="http://jungle-diaper-cakes.6xyotd.us/ " rel="nofollow">Jungle diaper cakes</a><a href="http://kimba-the-white-lion.6xyotd.us/ " rel="nofollow">Kimba the white lion</a><a href="http://julie-harris.6xyotd.us/ " rel="nofollow">Julie harris</a><a href="http://kona-hi.6xyotd.us/ " rel="nofollow">Kona hi</a><a href="http://kids-cowboy-boots.6xyotd.us/ " rel="nofollow">Kids cowboy boots</a><a href="http://kimora-simmons.6xyotd.us/ " rel="nofollow">Kimora simmons</a><a href="http://kermit-the-frog.6xyotd.us/ " rel="nofollow">Kermit the frog</a><a href="http://justin-nozuka.6xyotd.us/ " rel="nofollow">Justin nozuka</a><a href="http://katie-james-actress.6xyotd.us/ " rel="nofollow">Katie james actress</a><a href="http://king-neptune.6xyotd.us/ " rel="nofollow">King neptune</a> yefvo\',
    \'ofqqn\',
    \'[email protected]\'
);

//output
var_dump($response);

https://github.com/achingbrain/php5-akismet

结束

相关推荐

Custom Field & Gravity Forms

我有以下自定义函数代码,用于为帖子类型创建自定义字段。问题是,我需要自定义字段单独显示,此时它们只显示为“键”,这意味着当我尝试将表单字段(重力表单)链接到自定义字段时,我只能链接到“键”字段。如何修改此选项以单独显示每个自定义字段?/* Custom Fields */ $key = \"key\"; $meta_boxes = array( \"cf_link\" => array( \"name\" => \"cf_link\", \"title\