agencyrepublic / webpurify
实现网页净化的第三方PHP库
Requires
- php: >=5.3.0
- psr/log: ~1.0
Requires (Dev)
- monolog/monolog: 1.7.*@dev
- phpunit/phpunit: 3.7.*
Suggests
- monolog/monolog: Enables log messaging through the PSR-3 standard
This package is not auto-updated.
Last update: 2024-09-24 02:43:27 UTC
README
一个用于与 WebPurify 交互的库。
该库通过使用存根模拟进行PHPUnit测试,并且符合PSR-0、PSR-1、PSR-2和PSR-3规范。
安装
将以下内容添加到您的 composer.json
文件中。
{
"require": {
"agencyrepublic/webpurify": "dev-master"
}
}
使用方法
您可以使用以下两个类向Web Purify发送请求
WebPurify\WebPurifyImage
WebPurify\WebPurifyText
Web Purify文档上列出的大多数方法都可以用作API调用的方法名。但是,由于return
是PHP中的保留关键字,因此方法名为returnExpletives
。
WebPurify
这些方法在两个类中都可以使用。
setLogger
WebPurify类是一个符合PSR-3规范的LoggerAwareInterface。它将所有HTTP请求和响应输出到日志记录器。您需要一个日志记录器(例如Monolog)。
$logger = new Logger('name');
$logger->pushHandler(new StreamHandler('path/to/your.log'));
$webPurifyImage = new WebPurify\WebPurifyImage($apiKey);
$webPurifyImage->setLogger($logger);
getUseSSL
获取是否使用SSL进行请求。
var_dump($webPurifyImage->getUseSSL()); // bool(FALSE)
setUseSSL
设置是否使用SSL进行请求。默认值为false
。
$webPurifyImage->setUseSSL(true); // Use SSL in requests
WebPurifyImage
通过传递API密钥实例化WebPurifyImage
$webPurifyImage = new WebPurify\WebPurifyImage($apiKey);
imgCheck
返回: <imgid>
# string => imgurl
$webPurifyImage->imgCheck("http://.../");
# array => post data
$webPurifyImage->imgCheck(array(
"imgurl" => "http://.../"
// ...
));
imgStatus
返回
- true => 已批准
- false => 已拒绝
- null => 待处理
# string => imgid
$webPurifyImage->imgStatus("0123456789abcdef0123456789abcdef");
# array => post data
$webPurifyImage->imgCheck(array(
"imgid" => "0123456789abcdef0123456789abcdef"
// ...
));
imgAccount
返回: <remaining>
# No parameters
$webPurifyImage->imgAccount();
# array => post data
$webPurifyImage->imgAccount(array(
// ...
));
WebPurifyText
通过传递API密钥实例化WebPurifyText
$webPurifyText = new WebPurify\WebPurifyText($apiKey);
check
返回: boolean <found>
# string => text
$webPurifyText->check("the quick brown fox jumps over the lazy dog");
# array => post data
$webPurifyText->check(array(
"text" => "the quick brown fox jumps over the lazy dog"
// ...
));
checkCount
返回: boolean <found>
# string => text
$webPurifyText->checkCount("the quick brown fox jumps over the lazy dog");
# array => post data
$webPurifyText->check(array(
"text" => "the quick brown fox jumps over the lazy dog"
// ...
));
replace
返回: string <text>
# string => text
$webPurifyText->checkCount("the quick brown fox jumps over the lazy dog");
# array => post data
$webPurifyText->check(array(
"text" => "the quick brown fox jumps over the lazy dog"
// ...
));
returnExpletives
返回: array <word>
# string => text
$webPurifyText->returnExpletives("the quick brown fox jumps over the lazy dog");
# array => post data
$webPurifyText->returnExpletives(array(
"text" => "the quick brown fox jumps over the lazy dog"
// ...
));
addToBlackList
返回: boolean <success>
文档: webpurify.live.addtoblacklist
# string => text
$webPurifyText->addToBlackList("scunthorpe");
# array => post data
$webPurifyText->addToBlackList(array(
"word" => "scunthorpe"
// ...
));
addToWhiteList
返回: boolean <success>
文档: webpurify.live.addtowhitelist
# string => word
$webPurifyText->addToWhiteList("scunthorpe");
# array => post data
$webPurifyText->addToWhiteList(array(
"word" => "scunthorpe"
// ...
));
removeFromBlackList
返回: boolean <success>
文档: webpurify.live.removefromblacklist
# string => word
$webPurifyText->removeFromBlackList("scunthorpe");
# array => post data
$webPurifyText->removeFromBlackList(array(
"word" => "scunthorpe"
// ...
));
removeFromWhiteList
返回: boolean <success>
文档: webpurify.live.removefromwhitelist
# string => word
$webPurifyText->removeFromWhiteList("scunthorpe");
# array => post data
$webPurifyText->removeFromWhiteList(array(
"word" => "scunthorpe"
// ...
));
getBlackList
返回: array <word>
文档:webpurify.live.getblacklist
# No parameters
$webPurifyText->getBlackList();
# array => post data
$webPurifyText->getBlackList(array(
// ...
));
getWhiteList
返回: array <word>
文档:webpurify.live.getwhitelist
# No parameters
$webPurifyText->getWhiteList();
# array => post data
$webPurifyText->getWhiteList(array(
// ...
));