PHP SDK for NullNude API
, (*1)
This PHP SDK is a wrapper for our NullNude API,
a nudity detection/moderation service., (*2)
Use the NullNude API to instantly moderate adult content in user-submitted photos., (*3)
Installation
The NullNude PHP SDK can be installed with Composer., (*4)
php composer.phar require dneural/php-nullnude dev-master
or by adding the repository to your composer.json by hand:, (*5)
{
"require": {
"dneural/php-nullnude": "dev-master"
}
}
and then installing the SDK by running:, (*6)
php composer.phar install
Check the examples
directory to learn how to use the SDK effectivly., (*7)
Authenticate to NullNude API
Each application that uses NullNude API needs to be authenticated. For that
reason you will have to register an account with us. It is a very easy process
and can be done at this address: https://nullnude.com/register, (*8)
Write down your api_key and api_secret and you're ready to go., (*9)
Checking for nudity, regions of interest.
Checking if images contain nudity in them is easy. Provide an URL or a local
file path of the image you would like checked to one of the few methods that
our API supports., (*10)
<?php
require __DIR__ . '/vendor/autoload.php';
use NullNude\NullNude;
// Information about your API access.
$config = [
'api_key' => 'YOUR_API_KEY',
'api_secret' => 'YOUR_API_SECRET'
];
// Initialize the NullNude client.
$nullNude = new NullNude($config);
// Image can be either a local path or an external url.
$image = "https://nullnude.com/wp-content/uploads/2016/01/vintage_porn_2.jpg";
// Check if the image has nuidty in it.
$nudityResource = $nullNude->checkNudity($image);
if ( $nudityResource->hasNudity() ) {
// Take action based on your confidence preference.
echo 'Image nudity confidence: ' .
$nudityResource->getNudityConfidence();
}
// Get the array of regions of interest within the image.
$roiResource = $nullNude->getRoi($image);
echo "
";
print_r($roiResource->getRoi());
echo "
";
// Check if the image has been moderated, moderate.json
// applies the filter only if there was nudity present.
$moderateResource = $nullNude->moderate($image);
if ( $moderateResource->isModerated() ) {
// Download and save the moderated image.
echo 'Moderated image url: ' .
$moderateResource->getModeratedUrl();
}
Consider checking the examples
directory for more real life usage examples., (*11)
How to build the documentation?
Documentation is based on phpdocumentor. To install it clone the php-nullnude
project:, (*12)
git clone https://github.com/dneural/php-nullnude.git
cd php-nullnude
php composer.phar install
To generate documentation in the ./docs/nullnude directory run:, (*13)
./vendor/bin/phpdoc -d ./src -t ./docs/nullnude
How to run tests?
Tests are based on phpunit. To run them clone the php-nullnude
project:, (*14)
git clone https://github.com/dneural/php-nullnude.git
cd php-nullnude
php composer.phar install
and run this command:, (*15)
./vendor/bin/phpunit --coverage-text
License
The SDK code is released under a MIT style license, which means that it should
be easy to integrate it in your applications.
Check the LICENSE file for more information., (*16)