PHP code example of ikosar / lmfa

1. Go to this page and download the library: Download ikosar/lmfa 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/ */

    

ikosar / lmfa example snippets


 composer 

 php artisan vendor:publish 
 

  $face = new CheckFace();
 

    $face->setUrl($url);
  

    $face->setMethod("post");
  

    $face->getApiKey();
  

    $face->setHeaders(array(
       'Content-Type' => 'application/json',
       'Ocp-Apim-Subscription-Key' => $face->getApiKey(),
    ));
  

  $face->setParameters(array(
      'returnFaceId' => 'true', // Recommended : True 
      'returnFaceLandmarks' => 'false', // Very information about face sizes
      'returnFaceAttributes' => 'age,gender,glasses,smile,noise,hair,accessories,emotion,makeup', // Your Requsted info
  ));

  $image = array(
      'url' => 'http://cdn-tehran.wisgoon.com/dlir-s3/10531466806488528869.JPG',
  );
  $face->setBody($image,true); // Set Image
        

         $face->check();
         $face->send();        

         $face->check();
         $result = $face->send();
         // Now JSON in $result  
         return $result;      

        $image = array(
            'url' => 'https://upload.wikimedia.org/wikipedia/commons/thumb/d/d2/Donald_Trump_August_19%2C_2015_%28cropped%29.jpg/245px-Donald_Trump_August_19%2C_2015_%28cropped%29.jpg',
        );
        $url = "http://..."; 
        $face = new CheckFace();
        $face->setUrl($url);
        $face->setImage($image);
        $face->setMethod("post");
        $face->setHeaders(array(
            'Content-Type' => 'application/json',
            'Ocp-Apim-Subscription-Key' => $face->getApiKey(),
        ));
        $face->setParameters(array(
            'returnFaceId' => 'true',
            'returnFaceLandmarks' => 'false',
            'returnFaceAttributes' => 'age,gender,glasses,smile,noise,hair,accessories,emotion,makeup',
        ));
        $face->setBody($image);
        $face->check();
        $result = $face->send();
 
 lmfa.php