Web Purify API
, (*1)
A library for interfacing with WebPurify., (*2)
The library is covered by PHPUnit tests using stub mocks and is PSR-0, PSR-1, PSR-2 and PSR-3 compliant., (*3)
Installation
Add the following to your composer.json
., (*4)
{
"require": {
"agencyrepublic/webpurify": "dev-master"
}
}
Usage
There are two classes which you can use to make requests to Web Purify:, (*5)
WebPurify\WebPurifyImage
WebPurify\WebPurifyText
Most methods listed on the WebPurify documentation can be used as method names
for making API calls. There is exception as return
is a reserved keyword in
PHP the method name is returnExpletives
., (*6)
WebPurify
These methods are available in both classes., (*7)
setLogger
WebPurify class is a PSR-3 compliant LoggerAwareInterface. It outputs all HTTP
requests and responses to a logger. You will need a logger
(like Monolog)., (*8)
$logger = new Logger('name');
$logger->pushHandler(new StreamHandler('path/to/your.log'));
$webPurifyImage = new WebPurify\WebPurifyImage($apiKey);
$webPurifyImage->setLogger($logger);
getUseSSL
Get whether SSL will be used for requests., (*9)
var_dump($webPurifyImage->getUseSSL()); // bool(FALSE)
setUseSSL
Set whether SSL will be used for requests. The default is false
., (*10)
$webPurifyImage->setUseSSL(true); // Use SSL in requests
WebPurifyImage
Instantiate WebPurifyImage
by passing through your API key:, (*11)
$webPurifyImage = new WebPurify\WebPurifyImage($apiKey);
imgCheck
Returns: <imgid>, (*12)
Documentation:
webpurify.live.imgcheck, (*13)
# string => imgurl
$webPurifyImage->imgCheck("http://.../");
# array => post data
$webPurifyImage->imgCheck(array(
"imgurl" => "http://.../"
// ...
));
imgStatus
Returns:, (*14)
- true => approved
- false => declined
- null => pending
Documentation:
webpurify.live.imgstatus, (*15)
# string => imgid
$webPurifyImage->imgStatus("0123456789abcdef0123456789abcdef");
# array => post data
$webPurifyImage->imgCheck(array(
"imgid" => "0123456789abcdef0123456789abcdef"
// ...
));
imgAccount
Returns: <remaining>, (*16)
Documentation:
webpurify.live.imgaccount, (*17)
# No parameters
$webPurifyImage->imgAccount();
# array => post data
$webPurifyImage->imgAccount(array(
// ...
));
WebPurifyText
Instantiate WebPurifyTexxt
by passing through your API key:, (*18)
$webPurifyText = new WebPurify\WebPurifyText($apiKey);
check
Returns: boolean <found>, (*19)
Documentation:
webpurify.live.check, (*20)
# 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
Returns: boolean <found>, (*21)
Documentation:
webpurify.live.checkcount, (*22)
# 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
Returns: string <text>, (*23)
Documentation:
webpurify.live.replace, (*24)
# 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
Returns: array <word>, (*25)
Documentation:
webpurify.live.return, (*26)
# 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
Returns: boolean <success>, (*27)
Documentation:
webpurify.live.addtoblacklist, (*28)
# string => text
$webPurifyText->addToBlackList("scunthorpe");
# array => post data
$webPurifyText->addToBlackList(array(
"word" => "scunthorpe"
// ...
));
addToWhiteList
Returns: boolean <success>, (*29)
Documentation:
webpurify.live.addtowhitelist, (*30)
# string => word
$webPurifyText->addToWhiteList("scunthorpe");
# array => post data
$webPurifyText->addToWhiteList(array(
"word" => "scunthorpe"
// ...
));
removeFromBlackList
Returns: boolean <success>, (*31)
Documentation:
webpurify.live.removefromblacklist, (*32)
# string => word
$webPurifyText->removeFromBlackList("scunthorpe");
# array => post data
$webPurifyText->removeFromBlackList(array(
"word" => "scunthorpe"
// ...
));
removeFromWhiteList
Returns: boolean <success>, (*33)
Documentation:
webpurify.live.removefromwhitelist, (*34)
# string => word
$webPurifyText->removeFromWhiteList("scunthorpe");
# array => post data
$webPurifyText->removeFromWhiteList(array(
"word" => "scunthorpe"
// ...
));
getBlackList
Returns: array <word>, (*35)
Documentation:
webpurify.live.getblacklist, (*36)
# No parameters
$webPurifyText->getBlackList();
# array => post data
$webPurifyText->getBlackList(array(
// ...
));
getWhiteList
Returns: array <word>, (*37)
Documentation:
webpurify.live.getwhitelist, (*38)
# No parameters
$webPurifyText->getWhiteList();
# array => post data
$webPurifyText->getWhiteList(array(
// ...
));