PHP code example of dustindoiron / photodna-client

1. Go to this page and download the library: Download dustindoiron/photodna-client library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

dustindoiron / photodna-client example snippets


$configuration = new PhotoDNA\Configuration(
    apiKey: 'apiKey',
    endpoint: 'https://api.microsoftmoderator.com/photodna/v1.0/', // default
    ncmecUsername: 'ncmecUsername',
    ncmecPassword: 'ncmecPassword'
);
$client = new PhotoDNA\Client($configuration);

$imageFile = new PhotoDNA\Resource\ImageFile('/path/to/location');
$imageUrl = new PhotoDNA\Resource\ImageLocation('https://url.com/file.png');

$result = $client->match($imageFile);
// or
$result = $client->match($imageLocation);
// enhanced matching
$result = $client->match($imageFile, true);

// Fluently set

$violation = new PhotoDNA\Resource\Violation()
    ->set('IncidentTime', '9/10/2014 9:08:14 PM');
    ->set('ViolationContentCollection', [
        'Name' => $imageFile->getFilename(),
        'Value' => $imageFile->getBase64(),
        'UploadIpAddress' => '127.0.0.1',
        // etc
    ]);
$reporter = new PhotoDNA\Resource\Reporter()
    ->set('OrgName', 'ExampleOrgName');
    ->set('ReporterName', 'Example Reporter')
    ->set('ReporterEmail', '[email protected]');

$reportee = new PhotoDNA\Resource\Reportee()
    ->set('ReporteeName', 'Reportee Name')
    ->set('ReporteeIPAddress', '127.0.0.1');

$response = $client->report($reportee, $reporter, $violation, isTest: true);