1. Go to this page and download the library: Download sukuangyun/aip 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/ */
sukuangyun / aip example snippets
$rds = new \Redis();
$rds->connect('127.0.0.1', 6379);
$rds->auth('password');
$cache = new \Sukuangyun\Aip\Cache\RedisCache($rds);
$aip = new \Sukuangyun\Aip\Aip(
new \Sukuangyun\Aip\Config('appid', 'apikey', 'secretKey'),
$cache
);
// 在thinkphp中可以使用
// $aip = new Aip(new Config('appid', 'apikey', 'secretKey'), cache()->cache);
use Sukuangyun\Aip\Aip;
use Sukuangyun\Aip\Config;
d.jpg';
// $rs = file_get_contents($imagePath);
// $image = base64_encode($rs);
$aip = new Aip(new Config('appid', 'apikey', 'secretKey'));
$image = $aip->getImageBase64ByPath($imagePath);
$resp = $aip->idCard($image, 'back');
var_dump($resp);