1 官網下載sdk 一定要git 或者composer sdk: https://cloud.tencent.com/document/api/1007/33188
直接引用sdk 就可以 ,然后他的sdk有幾個是沒有引用路徑的 ,跟着報錯找到那個沒有引用,require_once 引用上就可以、
控制器代碼:
require_once (dirname(dirname(dirname((dirname(__FILE__))))).'/extend/TCloudAutoLoader.php');
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;
function carid(){
$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);
echo "<pre>";
print_r($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下載的地方在下載一個證書就可以了
