Skip to content
Permalink
master
Switch branches/tags
Go to file
…d recognition model: recognition_04.
1 contributor

Users who have contributed to this file

<?php
$ocpApimSubscriptionKey = getenv('FACE_SUBSCRIPTION_KEY');
$uriBase = getenv('FACE_ENDPOINT') . '/face/v1.0/';
$imageUrl =
'https://raw.githubusercontent.com/Azure-Samples/cognitive-services-sample-data-files/master/ComputerVision/Images/faces.jpg';
// This sample uses the PHP5 HTTP_Request2 package
// (https://pear.php.net/package/HTTP_Request2).
require_once 'HTTP/Request2.php';
$request = new Http_Request2($uriBase . '/detect');
$url = $request->getUrl();
$headers = array(
// Request headers
'Content-Type' => 'application/json',
'Ocp-Apim-Subscription-Key' => $ocpApimSubscriptionKey
);
$request->setHeader($headers);
$parameters = array(
// Request parameters
'detectionModel' => 'detection_03',
'returnFaceId' => 'true');
$url->setQueryVariables($parameters);
$request->setMethod(HTTP_Request2::METHOD_POST);
// Request body parameters
$body = json_encode(array('url' => $imageUrl));
// Request body
$request->setBody($body);
try
{
$response = $request->send();
echo "<pre>" .
json_encode(json_decode($response->getBody()), JSON_PRETTY_PRINT) . "</pre>";
}
catch (HttpException $ex)
{
echo "<pre>" . $ex . "</pre>";
}
?>