Composer 需要 PHP 5.3.2+ 以上版本,且需要开启 openssl。
中国大陆地区的用户可以使用腾讯云镜像源提高下载速度,在打开的命令窗口执行以下命令,更改 Packagist 为腾讯云镜像:
composer config -g repos.packagist composer https://mirrors.tencent.com/composer/
安装
composer require tencentcloud/tencentcloud-sdk-php
<?php
//前往 API 密钥管理 页面,即可进行获取。
$secret_id = "";
$secret_key = "";
$cred = new Credential($secret_id, $secret_key);
$httpProfile = new HttpProfile();
$httpProfile->setEndpoint("ocr.tencentcloudapi.com");
$clientProfile = new ClientProfile();
$clientProfile->setHttpProfile($httpProfile);
$client = new OcrClient($cred, "ap-beijing", $clientProfile);
$req = new IDCardOCRRequest();
$params = array(
"ImageUrl" => $image, //身份证图片地址
);
$req->fromJsonString(json_encode($params));
$resp = $client->IDCardOCR($req);
print_r($resp->toJsonString());
如果您的 PHP 环境证书有问题,可能会遇到报错,类似于cURL error 60: See http://curl.haxx.se/libcurl/c/libcurl-errors.html,请尝试按以下步骤解决:
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。