Permalink
Fetching contributors…
Cannot retrieve contributors at this time
583 lines (536 sloc) 24 KB
<?php
namespace VoiceIt;
class VoiceIt2 {
public $BASE_URL = 'https://api.voiceit.io';
public $api_key;
public $api_token;
public $platformId = '42';
function __construct($key, $token) {
$this->api_key = $key;
$this->api_token = $token;
}
function checkFileExists($file) {
if(!file_exists($file)){
throw new \Exception("File {$file} does not exist");
}
}
public function getPhrases($contentLanguage) {
$crl = curl_init();
curl_setopt($crl, CURLOPT_URL, $this->BASE_URL.'/phrases/'.$contentLanguage);
curl_setopt($crl, CURLOPT_USERPWD, "$this->api_key:$this->api_token");
curl_setopt($crl, CURLOPT_HTTPHEADER, array('platformId: '.$this->platformId));
curl_setopt($crl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($crl, CURLOPT_CUSTOMREQUEST, 'GET');
return curl_exec($crl);
}
public function getAllUsers() {
$crl = curl_init();
curl_setopt($crl, CURLOPT_URL, $this->BASE_URL.'/users');
curl_setopt($crl, CURLOPT_USERPWD, "$this->api_key:$this->api_token");
curl_setopt($crl, CURLOPT_HTTPHEADER, array('platformId: '.$this->platformId));
curl_setopt($crl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($crl, CURLOPT_CUSTOMREQUEST, 'GET');
return curl_exec($crl);
}
public function createUser() {
$crl = curl_init();
curl_setopt($crl, CURLOPT_URL, $this->BASE_URL.'/users');
curl_setopt($crl, CURLOPT_USERPWD, "$this->api_key:$this->api_token");
curl_setopt($crl, CURLOPT_HTTPHEADER, array('platformId: '.$this->platformId));
curl_setopt($crl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($crl, CURLOPT_CUSTOMREQUEST, 'POST');
return curl_exec($crl);
}
public function checkUserExists($userId) {
$crl = curl_init();
curl_setopt($crl, CURLOPT_URL, $this->BASE_URL.'/users/'.$userId);
curl_setopt($crl, CURLOPT_USERPWD, "$this->api_key:$this->api_token");
curl_setopt($crl, CURLOPT_HTTPHEADER, array('platformId: '.$this->platformId));
curl_setopt($crl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($crl, CURLOPT_CUSTOMREQUEST, 'GET');
return curl_exec($crl);
}
public function deleteUser($userId) {
$crl = curl_init();
curl_setopt($crl, CURLOPT_URL, $this->BASE_URL.'/users/'.$userId);
curl_setopt($crl, CURLOPT_USERPWD, "$this->api_key:$this->api_token");
curl_setopt($crl, CURLOPT_HTTPHEADER, array('platformId: '.$this->platformId));
curl_setopt($crl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($crl, CURLOPT_CUSTOMREQUEST, 'DELETE');
return curl_exec($crl);
}
public function getGroupsForUser($userId) {
$crl = curl_init();
curl_setopt($crl, CURLOPT_URL, $this->BASE_URL.'/users/'.$userId.'/groups');
curl_setopt($crl, CURLOPT_USERPWD, "$this->api_key:$this->api_token");
curl_setopt($crl, CURLOPT_HTTPHEADER, array('platformId: '.$this->platformId));
curl_setopt($crl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($crl, CURLOPT_CUSTOMREQUEST, 'GET');
return curl_exec($crl);
}
public function deleteAllEnrollments($userId) {
$crl = curl_init();
curl_setopt($crl, CURLOPT_URL, $this->BASE_URL.'/enrollments/'.$userId.'/all');
curl_setopt($crl, CURLOPT_USERPWD, "$this->api_key:$this->api_token");
curl_setopt($crl, CURLOPT_HTTPHEADER, array('platformId: '.$this->platformId));
curl_setopt($crl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($crl, CURLOPT_CUSTOMREQUEST, 'DELETE');
return curl_exec($crl);
}
public function getAllVoiceEnrollments($userId) {
$crl = curl_init();
curl_setopt($crl, CURLOPT_URL, $this->BASE_URL.'/enrollments/voice/'.$userId);
curl_setopt($crl, CURLOPT_USERPWD, "$this->api_key:$this->api_token");
curl_setopt($crl, CURLOPT_HTTPHEADER, array('platformId: '.$this->platformId));
curl_setopt($crl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($crl, CURLOPT_CUSTOMREQUEST, 'GET');
return curl_exec($crl);
}
public function getAllFaceEnrollments($userId) {
$crl = curl_init();
curl_setopt($crl, CURLOPT_URL, $this->BASE_URL.'/enrollments/face/'.$userId);
curl_setopt($crl, CURLOPT_USERPWD, "$this->api_key:$this->api_token");
curl_setopt($crl, CURLOPT_HTTPHEADER, array('platformId: '.$this->platformId));
curl_setopt($crl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($crl, CURLOPT_CUSTOMREQUEST, 'GET');
return curl_exec($crl);
}
public function getAllVideoEnrollments($userId) {
$crl = curl_init();
curl_setopt($crl, CURLOPT_URL, $this->BASE_URL.'/enrollments/video/'.$userId);
curl_setopt($crl, CURLOPT_USERPWD, "$this->api_key:$this->api_token");
curl_setopt($crl, CURLOPT_HTTPHEADER, array('platformId: '.$this->platformId));
curl_setopt($crl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($crl, CURLOPT_CUSTOMREQUEST, 'GET');
return curl_exec($crl);
}
public function createVoiceEnrollment($userId, $contentLanguage, $phrase, $filePath) {
$this->checkFileExists($filePath);
$crl = curl_init();
curl_setopt($crl, CURLOPT_URL, $this->BASE_URL.'/enrollments/voice');
curl_setopt($crl, CURLOPT_USERPWD, "$this->api_key:$this->api_token");
curl_setopt($crl, CURLOPT_HTTPHEADER, array('platformId: '.$this->platformId));
curl_setopt($crl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($crl, CURLOPT_CUSTOMREQUEST, 'POST');
$fields = [
'userId' => $userId,
'contentLanguage' => $contentLanguage,
'phrase' => $phrase,
'recording' => curl_file_create($filePath)
];
curl_setopt($crl, CURLOPT_POSTFIELDS, $fields);
return curl_exec($crl);
}
public function createVoiceEnrollmentByUrl($userId, $contentLanguage, $phrase, $fileUrl) {
$crl = curl_init();
curl_setopt($crl, CURLOPT_URL, $this->BASE_URL.'/enrollments/voice/byUrl');
curl_setopt($crl, CURLOPT_USERPWD, "$this->api_key:$this->api_token");
curl_setopt($crl, CURLOPT_HTTPHEADER, array('platformId: '.$this->platformId));
curl_setopt($crl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($crl, CURLOPT_CUSTOMREQUEST, 'POST');
$fields = [
'userId' => $userId,
'contentLanguage' => $contentLanguage,
'phrase' => $phrase,
'fileUrl' => $fileUrl
];
curl_setopt($crl, CURLOPT_POSTFIELDS, $fields);
return curl_exec($crl);
}
public function createFaceEnrollment($userId, $filePath, $doBlinkDetection = false) {
$this->checkFileExists($filePath);
$crl = curl_init();
curl_setopt($crl, CURLOPT_URL, $this->BASE_URL.'/enrollments/face');
curl_setopt($crl, CURLOPT_USERPWD, "$this->api_key:$this->api_token");
curl_setopt($crl, CURLOPT_HTTPHEADER, array('platformId: '.$this->platformId));
curl_setopt($crl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($crl, CURLOPT_CUSTOMREQUEST, 'POST');
$fields = [
'userId' => $userId,
'doBlinkDetection' => $doBlinkDetection ? 1 : 0,
'video' => curl_file_create($filePath)
];
curl_setopt($crl, CURLOPT_POSTFIELDS, $fields);
return curl_exec($crl);
}
public function createFaceEnrollmentByUrl($userId, $fileUrl, $doBlinkDetection = false) {
$crl = curl_init();
curl_setopt($crl, CURLOPT_URL, $this->BASE_URL.'/enrollments/face/byUrl');
curl_setopt($crl, CURLOPT_USERPWD, "$this->api_key:$this->api_token");
curl_setopt($crl, CURLOPT_HTTPHEADER, array('platformId: '.$this->platformId));
curl_setopt($crl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($crl, CURLOPT_CUSTOMREQUEST, 'POST');
$fields = [
'userId' => $userId,
'doBlinkDetection' => $doBlinkDetection ? 1 : 0,
'fileUrl' => $fileUrl
];
curl_setopt($crl, CURLOPT_POSTFIELDS, $fields);
return curl_exec($crl);
}
public function createVideoEnrollment($userId, $contentLanguage, $phrase, $filePath, $doBlinkDetection = false) {
$this->checkFileExists($filePath);
$crl = curl_init();
curl_setopt($crl, CURLOPT_URL, $this->BASE_URL.'/enrollments/video');
curl_setopt($crl, CURLOPT_USERPWD, "$this->api_key:$this->api_token");
curl_setopt($crl, CURLOPT_HTTPHEADER, array('platformId: '.$this->platformId));
curl_setopt($crl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($crl, CURLOPT_CUSTOMREQUEST, 'POST');
$fields = [
'userId' => $userId,
'contentLanguage' => $contentLanguage,
'phrase' => $phrase,
'doBlinkDetection' => $doBlinkDetection ? 1 : 0,
'video' => curl_file_create($filePath)
];
curl_setopt($crl, CURLOPT_POSTFIELDS, $fields);
return curl_exec($crl);
}
public function createVideoEnrollmentByUrl($userId, $contentLanguage, $phrase, $fileUrl, $doBlinkDetection = false) {
$crl = curl_init();
curl_setopt($crl, CURLOPT_URL, $this->BASE_URL.'/enrollments/video/byUrl');
curl_setopt($crl, CURLOPT_USERPWD, "$this->api_key:$this->api_token");
curl_setopt($crl, CURLOPT_HTTPHEADER, array('platformId: '.$this->platformId));
curl_setopt($crl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($crl, CURLOPT_CUSTOMREQUEST, 'POST');
$fields = [
'userId' => $userId,
'contentLanguage' => $contentLanguage,
'phrase' => $phrase,
'doBlinkDetection' => $doBlinkDetection ? 1 : 0,
'fileUrl' => $fileUrl
];
curl_setopt($crl, CURLOPT_POSTFIELDS, $fields);
return curl_exec($crl);
}
public function deleteAllVoiceEnrollments($userId) {
$crl = curl_init();
curl_setopt($crl, CURLOPT_URL, $this->BASE_URL.'/enrollments/'.$userId.'/voice');
curl_setopt($crl, CURLOPT_USERPWD, "$this->api_key:$this->api_token");
curl_setopt($crl, CURLOPT_HTTPHEADER, array('platformId: '.$this->platformId));
curl_setopt($crl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($crl, CURLOPT_CUSTOMREQUEST, 'DELETE');
return curl_exec($crl);
}
public function deleteAllFaceEnrollments($userId) {
$crl = curl_init();
curl_setopt($crl, CURLOPT_URL, $this->BASE_URL.'/enrollments/'.$userId.'/face');
curl_setopt($crl, CURLOPT_USERPWD, "$this->api_key:$this->api_token");
curl_setopt($crl, CURLOPT_HTTPHEADER, array('platformId: '.$this->platformId));
curl_setopt($crl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($crl, CURLOPT_CUSTOMREQUEST, 'DELETE');
return curl_exec($crl);
}
public function deleteAllVideoEnrollments($userId) {
$crl = curl_init();
curl_setopt($crl, CURLOPT_URL, $this->BASE_URL.'/enrollments/'.$userId.'/video');
curl_setopt($crl, CURLOPT_USERPWD, "$this->api_key:$this->api_token");
curl_setopt($crl, CURLOPT_HTTPHEADER, array('platformId: '.$this->platformId));
curl_setopt($crl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($crl, CURLOPT_CUSTOMREQUEST, 'DELETE');
return curl_exec($crl);
}
public function deleteVoiceEnrollment($userId, $enrollmentId) {
$crl = curl_init();
curl_setopt($crl, CURLOPT_URL, $this->BASE_URL.'/enrollments/voice/'.$userId.'/'.strval($enrollmentId));
curl_setopt($crl, CURLOPT_USERPWD, "$this->api_key:$this->api_token");
curl_setopt($crl, CURLOPT_HTTPHEADER, array('platformId: '.$this->platformId));
curl_setopt($crl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($crl, CURLOPT_CUSTOMREQUEST, 'DELETE');
return curl_exec($crl);
}
public function deleteFaceEnrollment($userId, $faceEnrollmentId) {
$crl = curl_init();
curl_setopt($crl, CURLOPT_URL, $this->BASE_URL.'/enrollments/face/'.$userId.'/'.strval($faceEnrollmentId));
curl_setopt($crl, CURLOPT_USERPWD, "$this->api_key:$this->api_token");
curl_setopt($crl, CURLOPT_HTTPHEADER, array('platformId: '.$this->platformId));
curl_setopt($crl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($crl, CURLOPT_CUSTOMREQUEST, 'DELETE');
return curl_exec($crl);
}
public function deleteVideoEnrollment($userId, $enrollmentId) {
$crl = curl_init();
curl_setopt($crl, CURLOPT_URL, $this->BASE_URL.'/enrollments/video/'.$userId.'/'.strval($enrollmentId));
curl_setopt($crl, CURLOPT_USERPWD, "$this->api_key:$this->api_token");
curl_setopt($crl, CURLOPT_HTTPHEADER, array('platformId: '.$this->platformId));
curl_setopt($crl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($crl, CURLOPT_CUSTOMREQUEST, 'DELETE');
return curl_exec($crl);
}
public function getAllGroups() {
$crl = curl_init();
curl_setopt($crl, CURLOPT_URL, $this->BASE_URL.'/groups');
curl_setopt($crl, CURLOPT_USERPWD, "$this->api_key:$this->api_token");
curl_setopt($crl, CURLOPT_HTTPHEADER, array('platformId: '.$this->platformId));
curl_setopt($crl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($crl, CURLOPT_CUSTOMREQUEST, 'GET');
return curl_exec($crl);
}
public function getGroup($groupId) {
$crl = curl_init();
curl_setopt($crl, CURLOPT_URL, $this->BASE_URL.'/groups/'.$groupId);
curl_setopt($crl, CURLOPT_USERPWD, "$this->api_key:$this->api_token");
curl_setopt($crl, CURLOPT_HTTPHEADER, array('platformId: '.$this->platformId));
curl_setopt($crl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($crl, CURLOPT_CUSTOMREQUEST, 'GET');
return curl_exec($crl);
}
public function groupExists($groupId) {
$crl = curl_init();
curl_setopt($crl, CURLOPT_URL, $this->BASE_URL.'/groups/'.$groupId.'/exists');
curl_setopt($crl, CURLOPT_USERPWD, "$this->api_key:$this->api_token");
curl_setopt($crl, CURLOPT_HTTPHEADER, array('platformId: '.$this->platformId));
curl_setopt($crl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($crl, CURLOPT_CUSTOMREQUEST, 'GET');
return curl_exec($crl);
}
public function createGroup($description) {
$crl = curl_init();
curl_setopt($crl, CURLOPT_URL, $this->BASE_URL.'/groups');
curl_setopt($crl, CURLOPT_USERPWD, "$this->api_key:$this->api_token");
curl_setopt($crl, CURLOPT_HTTPHEADER, array('platformId: '.$this->platformId));
curl_setopt($crl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($crl, CURLOPT_CUSTOMREQUEST, 'POST');
$fields = [
'description' => $description
];
curl_setopt($crl, CURLOPT_POSTFIELDS, $fields);
return curl_exec($crl);
}
public function addUserToGroup($groupId, $userId) {
$crl = curl_init();
curl_setopt($crl, CURLOPT_URL, $this->BASE_URL.'/groups/addUser');
curl_setopt($crl, CURLOPT_USERPWD, "$this->api_key:$this->api_token");
curl_setopt($crl, CURLOPT_HTTPHEADER, array('platformId: '.$this->platformId));
curl_setopt($crl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($crl, CURLOPT_CUSTOMREQUEST, 'PUT');
$fields = [
'groupId' => $groupId,
'userId' => $userId
];
curl_setopt($crl, CURLOPT_POSTFIELDS, $fields);
return curl_exec($crl);
}
public function removeUserFromGroup($groupId, $userId) {
$crl = curl_init();
curl_setopt($crl, CURLOPT_URL, $this->BASE_URL.'/groups/removeUser');
curl_setopt($crl, CURLOPT_USERPWD, "$this->api_key:$this->api_token");
curl_setopt($crl, CURLOPT_HTTPHEADER, array('platformId: '.$this->platformId));
curl_setopt($crl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($crl, CURLOPT_CUSTOMREQUEST, 'PUT');
$fields = [
'groupId' => $groupId,
'userId' => $userId
];
curl_setopt($crl, CURLOPT_POSTFIELDS, $fields);
return curl_exec($crl);
}
public function deleteGroup($groupId) {
$crl = curl_init();
curl_setopt($crl, CURLOPT_URL, $this->BASE_URL.'/groups/'.$groupId);
curl_setopt($crl, CURLOPT_USERPWD, "$this->api_key:$this->api_token");
curl_setopt($crl, CURLOPT_HTTPHEADER, array('platformId: '.$this->platformId));
curl_setopt($crl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($crl, CURLOPT_CUSTOMREQUEST, 'DELETE');
return curl_exec($crl);
}
public function voiceVerification($userId, $contentLanguage, $phrase, $filePath) {
$this->checkFileExists($filePath);
$crl = curl_init();
curl_setopt($crl, CURLOPT_URL, $this->BASE_URL.'/verification/voice');
curl_setopt($crl, CURLOPT_USERPWD, "$this->api_key:$this->api_token");
curl_setopt($crl, CURLOPT_HTTPHEADER, array('platformId: '.$this->platformId));
curl_setopt($crl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($crl, CURLOPT_CUSTOMREQUEST, 'POST');
$fields = [
'userId' => $userId,
'contentLanguage' => $contentLanguage,
'phrase' => $phrase,
'recording' => curl_file_create($filePath)
];
curl_setopt($crl, CURLOPT_POSTFIELDS, $fields);
return curl_exec($crl);
}
public function voiceVerificationByUrl($userId, $contentLanguage, $phrase, $fileUrl) {
$crl = curl_init();
curl_setopt($crl, CURLOPT_URL, $this->BASE_URL.'/verification/voice/byUrl');
curl_setopt($crl, CURLOPT_USERPWD, "$this->api_key:$this->api_token");
curl_setopt($crl, CURLOPT_HTTPHEADER, array('platformId: '.$this->platformId));
curl_setopt($crl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($crl, CURLOPT_CUSTOMREQUEST, 'POST');
$fields = [
'userId' => $userId,
'contentLanguage' => $contentLanguage,
'phrase' => $phrase,
'fileUrl' => $fileUrl
];
curl_setopt($crl, CURLOPT_POSTFIELDS, $fields);
return curl_exec($crl);
}
public function faceVerification($userId, $filePath, $doBlinkDetection = false) {
$this->checkFileExists($filePath);
$crl = curl_init();
curl_setopt($crl, CURLOPT_URL, $this->BASE_URL.'/verification/face');
curl_setopt($crl, CURLOPT_USERPWD, "$this->api_key:$this->api_token");
curl_setopt($crl, CURLOPT_HTTPHEADER, array('platformId: '.$this->platformId));
curl_setopt($crl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($crl, CURLOPT_CUSTOMREQUEST, 'POST');
$fields = [
'userId' => $userId,
'doBlinkDetection' => $doBlinkDetection ? 1 : 0,
'video' => curl_file_create($filePath)
];
curl_setopt($crl, CURLOPT_POSTFIELDS, $fields);
return curl_exec($crl);
}
public function faceVerificationByUrl($userId, $fileUrl, $doBlinkDetection = false) {
$crl = curl_init();
curl_setopt($crl, CURLOPT_URL, $this->BASE_URL.'/verification/face/byUrl');
curl_setopt($crl, CURLOPT_USERPWD, "$this->api_key:$this->api_token");
curl_setopt($crl, CURLOPT_HTTPHEADER, array('platformId: '.$this->platformId));
curl_setopt($crl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($crl, CURLOPT_CUSTOMREQUEST, 'POST');
$fields = [
'userId' => $userId,
'doBlinkDetection' => $doBlinkDetection ? 1 : 0,
'fileUrl' => $fileUrl
];
curl_setopt($crl, CURLOPT_POSTFIELDS, $fields);
return curl_exec($crl);
}
public function videoVerification($userId, $contentLanguage, $phrase, $filePath, $doBlinkDetection = false) {
$this->checkFileExists($filePath);
$crl = curl_init();
curl_setopt($crl, CURLOPT_URL, $this->BASE_URL.'/verification/video');
curl_setopt($crl, CURLOPT_USERPWD, "$this->api_key:$this->api_token");
curl_setopt($crl, CURLOPT_HTTPHEADER, array('platformId: '.$this->platformId));
curl_setopt($crl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($crl, CURLOPT_CUSTOMREQUEST, 'POST');
$fields = [
'userId' => $userId,
'contentLanguage' => $contentLanguage,
'phrase' => $phrase,
'doBlinkDetection' => $doBlinkDetection ? 1 : 0,
'video' => curl_file_create($filePath)
];
curl_setopt($crl, CURLOPT_POSTFIELDS, $fields);
return curl_exec($crl);
}
public function videoVerificationByUrl($userId, $contentLanguage, $phrase, $fileUrl, $doBlinkDetection = false) {
$crl = curl_init();
curl_setopt($crl, CURLOPT_URL, $this->BASE_URL.'/verification/video/byUrl');
curl_setopt($crl, CURLOPT_USERPWD, "$this->api_key:$this->api_token");
curl_setopt($crl, CURLOPT_HTTPHEADER, array('platformId: '.$this->platformId));
curl_setopt($crl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($crl, CURLOPT_CUSTOMREQUEST, 'POST');
$fields = [
'userId' => $userId,
'contentLanguage' => $contentLanguage,
'phrase' => $phrase,
'doBlinkDetection' => $doBlinkDetection ? 1 : 0,
'fileUrl' => $fileUrl
];
curl_setopt($crl, CURLOPT_POSTFIELDS, $fields);
return curl_exec($crl);
}
public function voiceIdentification($groupId, $contentLanguage, $phrase, $filePath) {
$this->checkFileExists($filePath);
$crl = curl_init();
curl_setopt($crl, CURLOPT_URL, $this->BASE_URL.'/identification/voice');
curl_setopt($crl, CURLOPT_USERPWD, "$this->api_key:$this->api_token");
curl_setopt($crl, CURLOPT_HTTPHEADER, array('platformId: '.$this->platformId));
curl_setopt($crl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($crl, CURLOPT_CUSTOMREQUEST, 'POST');
$fields = [
'groupId' => $groupId,
'contentLanguage' => $contentLanguage,
'phrase' => $phrase,
'recording' => curl_file_create($filePath)
];
curl_setopt($crl, CURLOPT_POSTFIELDS, $fields);
return curl_exec($crl);
}
public function voiceIdentificationByUrl($groupId, $contentLanguage, $phrase, $fileUrl) {
$crl = curl_init();
curl_setopt($crl, CURLOPT_URL, $this->BASE_URL.'/identification/voice/byUrl');
curl_setopt($crl, CURLOPT_USERPWD, "$this->api_key:$this->api_token");
curl_setopt($crl, CURLOPT_HTTPHEADER, array('platformId: '.$this->platformId));
curl_setopt($crl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($crl, CURLOPT_CUSTOMREQUEST, 'POST');
$fields = [
'groupId' => $groupId,
'contentLanguage' => $contentLanguage,
'phrase' => $phrase,
'fileUrl' => $fileUrl
];
curl_setopt($crl, CURLOPT_POSTFIELDS, $fields);
return curl_exec($crl);
}
public function faceIdentification($groupId, $filePath, $doBlinkDetection = false) {
$this->checkFileExists($filePath);
$crl = curl_init();
curl_setopt($crl, CURLOPT_URL, $this->BASE_URL.'/identification/face');
curl_setopt($crl, CURLOPT_USERPWD, "$this->api_key:$this->api_token");
curl_setopt($crl, CURLOPT_HTTPHEADER, array('platformId: '.$this->platformId));
curl_setopt($crl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($crl, CURLOPT_CUSTOMREQUEST, 'POST');
$fields = [
'groupId' => $groupId,
'doBlinkDetection' => $doBlinkDetection ? 1 : 0,
'video' => curl_file_create($filePath)
];
curl_setopt($crl, CURLOPT_POSTFIELDS, $fields);
return curl_exec($crl);
}
public function faceIdentificationByUrl($groupId, $fileUrl, $doBlinkDetection = false) {
$crl = curl_init();
curl_setopt($crl, CURLOPT_URL, $this->BASE_URL.'/identification/face/byUrl');
curl_setopt($crl, CURLOPT_USERPWD, "$this->api_key:$this->api_token");
curl_setopt($crl, CURLOPT_HTTPHEADER, array('platformId: '.$this->platformId));
curl_setopt($crl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($crl, CURLOPT_CUSTOMREQUEST, 'POST');
$fields = [
'groupId' => $groupId,
'doBlinkDetection' => $doBlinkDetection ? 1 : 0,
'fileUrl' => $fileUrl
];
curl_setopt($crl, CURLOPT_POSTFIELDS, $fields);
return curl_exec($crl);
}
public function videoIdentification($groupId, $contentLanguage, $phrase, $filePath, $doBlinkDetection = false) {
$this->checkFileExists($filePath);
$crl = curl_init();
curl_setopt($crl, CURLOPT_URL, $this->BASE_URL.'/identification/video');
curl_setopt($crl, CURLOPT_USERPWD, "$this->api_key:$this->api_token");
curl_setopt($crl, CURLOPT_HTTPHEADER, array('platformId: '.$this->platformId));
curl_setopt($crl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($crl, CURLOPT_CUSTOMREQUEST, 'POST');
$fields = [
'groupId' => $groupId,
'contentLanguage' => $contentLanguage,
'phrase' => $phrase,
'doBlinkDetection' => $doBlinkDetection ? 1 : 0,
'video' => curl_file_create($filePath)
];
curl_setopt($crl, CURLOPT_POSTFIELDS, $fields);
return curl_exec($crl);
}
public function videoIdentificationByUrl($groupId, $contentLanguage, $phrase, $fileUrl, $doBlinkDetection = false) {
$crl = curl_init();
curl_setopt($crl, CURLOPT_URL, $this->BASE_URL.'/identification/video/byUrl');
curl_setopt($crl, CURLOPT_USERPWD, "$this->api_key:$this->api_token");
curl_setopt($crl, CURLOPT_HTTPHEADER, array('platformId: '.$this->platformId));
curl_setopt($crl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($crl, CURLOPT_CUSTOMREQUEST, 'POST');
$fields = [
'groupId' => $groupId,
'contentLanguage' => $contentLanguage,
'phrase' => $phrase,
'doBlinkDetection' => $doBlinkDetection ? 1 : 0,
'fileUrl' => $fileUrl
];
curl_setopt($crl, CURLOPT_POSTFIELDS, $fields);
return curl_exec($crl);
}
}
?>