PHP code example of ctexthuang / aip_sdk

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

    

ctexthuang / aip_sdk example snippets


use ctexthuang\aip_sdk\AipFace;
// or other services like:
// use ctexthuang\aip_sdk\AipOcr;
// use ctexthuang\aip_sdk\AipNlp;

$appId = 'YOUR_APP_ID';
$apiKey = 'YOUR_API_KEY';
$secretKey = 'YOUR_SECRET_KEY';

$client = new AipFace($appId, $apiKey, $secretKey);

$image = file_get_contents('path/to/image.jpg');
$imageType = 'BASE64';
$image = base64_encode($image);

// Detect face
$result = $client->detect($image, $imageType);
print_r($result);

use ctexthuang\aip_sdk\AipOcr;

$client = new AipOcr($appId, $apiKey, $secretKey);

$image = file_get_contents('path/to/image.jpg');
$result = $client->basicGeneral($image);
print_r($result);