1 官網下載sdk 必定要git 或者composer sdk: https://cloud.tencent.com/document/api/1007/33188 php
直接引用sdk 就能夠 ,而後他的sdk有幾個是沒有引用路徑的 ,跟着報錯找到那個沒有引用,require_once 引用上就能夠、html
控制器代碼:git
require_once (dirname(dirname(dirname((dirname(__FILE__))))).'/extend/TCloudAutoLoader.php');json
use TencentCloud\Common\Credential;
use TencentCloud\Common\Profile\ClientProfile;
use TencentCloud\Common\Profile\HttpProfile;
use TencentCloud\Common\Exception\TencentCloudSDKException;
use TencentCloud\Faceid\V20180301\FaceidClient;
use TencentCloud\Faceid\V20180301\Models\IdCardVerificationRequest;api
function carid(){composer
$cred = new Credential("騰訊雲申請的SecretId", "騰訊雲申請的SecretKey ");
$httpProfile = new HttpProfile();
$httpProfile->setEndpoint("faceid.tencentcloudapi.com");
$clientProfile = new ClientProfile();
$clientProfile->setHttpProfile($httpProfile);
$client = new FaceidClient($cred, "ap-beijing", $clientProfile);
$req = new IdCardVerificationRequest();
$params = json_encode(array('IdCard'=>'身份證號','Name'=>‘姓名’));
$req->fromJsonString($params);
$resp = $client->IdCardVerification($req);
$code = json_decode($resp->toJsonString(),true);curl
echo "<pre>";ui
print_r($code);url
}code
若是報了一個相似於
[TencentCloud\Common\Exception\TencentCloudSDKException] code: message:cURL error 60: SSL certificate problem: self signed certificate in certificate chain (see http://curl.haxx.se/libcurl/c/libcurl-errors.html) requestId:
這個錯 就是證書的問題
去sdk下載的地方在下載一個證書就能夠了