package main import ( "fmt" "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common" "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/errors" "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/profile" ocr "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/ocr/v20181119" ) func main() { credential := common.NewCredential( "sid", "skey", ) cpf := profile.NewClientProfile() cpf.HttpProfile.Endpoint = "ocr.tencentcloudapi.com" client, _ := ocr.NewClient(credential, "ap-guangzhou", cpf) request := ocr.NewIDCardOCRRequest() //request.ImageUrl = common.StringPtr("http://n.sinaimg.cn/front20200924ac/443/w1184h859/20200924/888d-izrvxmf1170471.png") //request.CardSide = common.StringPtr("FRONT") request.ImageUrl = common.StringPtr("https://ss1.baidu.com/-4o3dSag_xI4khGko9WTAnF6hhy/baike/pic/item/e1fe9925bc315c6018cf3d0481b1cb1348547786.jpg") request.CardSide = common.StringPtr("BACK") response, err := client.IDCardOCR(request) if _, ok := err.(*errors.TencentCloudSDKError); ok { fmt.Printf("An API error has returned: %s", err) return } if err != nil { panic(err) } fmt.Printf("%s", response.ToJsonString()) }
https://cloud.tencent.com/document/product/866/33524