agencyrepublic/webpurify

A third-party PHP library for implementing web purify

v1.0.3 2016-10-20 16:25 UTC

This package is not auto-updated.

Last update: 2024-11-05 03:16:20 UTC


README

Build Status

A library for interfacing with WebPurify.

The library is covered by PHPUnit tests using stub mocks and is PSR-0, PSR-1, PSR-2 and PSR-3 compliant.

Installation

Add the following to your composer.json.

{
	"require": {
		"agencyrepublic/webpurify": "dev-master"
	}
}

Usage

There are two classes which you can use to make requests to Web Purify:

  • 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.

WebPurify

These methods are available in both classes.

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).

$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.

var_dump($webPurifyImage->getUseSSL()); // bool(FALSE)

setUseSSL

Set whether SSL will be used for requests. The default is false.

$webPurifyImage->setUseSSL(true); // Use SSL in requests

WebPurifyImage

Instantiate WebPurifyImage by passing through your API key:

$webPurifyImage = new WebPurify\WebPurifyImage($apiKey);

imgCheck

Returns: <imgid>

Documentation: webpurify.live.imgcheck

# string => imgurl
$webPurifyImage->imgCheck("http://.../");

# array => post data
$webPurifyImage->imgCheck(array(
	"imgurl" => "http://.../"
	// ...
));

imgStatus

Returns:

  • true => approved
  • false => declined
  • null => pending

Documentation: webpurify.live.imgstatus

# string => imgid
$webPurifyImage->imgStatus("0123456789abcdef0123456789abcdef");

# array => post data
$webPurifyImage->imgCheck(array(
	"imgid" => "0123456789abcdef0123456789abcdef"
	// ...
));

imgAccount

Returns: <remaining>

Documentation: webpurify.live.imgaccount

# No parameters
$webPurifyImage->imgAccount();

# array => post data
$webPurifyImage->imgAccount(array(
	// ...
));

WebPurifyText

Instantiate WebPurifyTexxt by passing through your API key:

$webPurifyText = new WebPurify\WebPurifyText($apiKey);

check

Returns: boolean <found>

Documentation: webpurify.live.check

# 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>

Documentation: webpurify.live.checkcount

# 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>

Documentation: webpurify.live.replace

# 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>

Documentation: webpurify.live.return

# 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>

Documentation: webpurify.live.addtoblacklist

# string => text
$webPurifyText->addToBlackList("scunthorpe");

# array => post data
$webPurifyText->addToBlackList(array(
	"word" => "scunthorpe"
	// ...
));

addToWhiteList

Returns: boolean <success>

Documentation: webpurify.live.addtowhitelist

# string => word
$webPurifyText->addToWhiteList("scunthorpe");

# array => post data
$webPurifyText->addToWhiteList(array(
	"word" => "scunthorpe"
	// ...
));

removeFromBlackList

Returns: boolean <success>

Documentation: webpurify.live.removefromblacklist

# string => word
$webPurifyText->removeFromBlackList("scunthorpe");

# array => post data
$webPurifyText->removeFromBlackList(array(
	"word" => "scunthorpe"
	// ...
));

removeFromWhiteList

Returns: boolean <success>

Documentation: webpurify.live.removefromwhitelist

# string => word
$webPurifyText->removeFromWhiteList("scunthorpe");

# array => post data
$webPurifyText->removeFromWhiteList(array(
	"word" => "scunthorpe"
	// ...
));

getBlackList

Returns: array <word>

Documentation: webpurify.live.getblacklist

# No parameters
$webPurifyText->getBlackList();

# array => post data
$webPurifyText->getBlackList(array(
	// ...
));

getWhiteList

Returns: array <word>

Documentation: webpurify.live.getwhitelist

# No parameters
$webPurifyText->getWhiteList();

# array => post data
$webPurifyText->getWhiteList(array(
	// ...
));