- Модуль: faceid
- Путь к файлу: ~/bitrix/modules/faceid/lib/photoidentifierfindface.php
- Класс: BitrixFaceIdPhotoIdentifierFindFace
- Вызов: PhotoIdentifierFindFace::addPerson
public function addPerson($imageContent, $meta, $galleryId = null)
{
$success = false;
$id = '';
$http = new BitrixMainWebHttpClient();
$resource = fopen($imageContent, 'r');
try
{
$http->setHeader('Authorization', 'Token '.$this->token);
$response = $http->post('https://api.findface.pro/face/', array(
'photo' => $resource,
'meta' => $meta,
'galleries' => $galleryId
), true);
if ($http->getStatus() == 200)
{
$body = json_decode($response, true);
if (!empty($body['id']))
{
$success = true;
$id = $body['id'];
$msg = 'added '.$body['meta'].' ('.$body['id'].')';
}
else
{
$msg = 'fail: '.$body['code'].' '.$body['reason'];
}
}
else
{
$msg = $http->getStatus().': '.$response;
}
}
catch (Exception $e)
{
$msg = $e->getMessage();
}
return array(
'result' => $success,
'face_id' => $id,
'msg' => $msg
);
}