dustindoiron/photodna-client

此包最新版本(v1.0.0)没有可用的许可信息。

一个 MSFT PhotoDNA 客户端,用 PHP 编写

v1.0.0 2024-07-23 21:45 UTC

This package is auto-updated.

Last update: 2024-09-24 01:25:53 UTC


README

这是一个基本的用于微软 PhotoDNA 服务的 Match 和 Report API 客户端。在使用此客户端之前,您应该拥有有效的 PhotoDNA 调解账户以及 NCMEC 联系人。

使用方法:创建一个客户端...

$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', 'test@example.com');

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

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