现如今,随着实名制的实施,各行各业都将进行人员身份的核查,如家政、保洁、物流、金融、电商等,身份证实名认证接口主要是验证个人用户提交的姓名、人像和身份证号码信息,和公安数据库内对应的数据是否匹配一致,可以验证个人身份证信息的真伪。
以下是C++语言调用翔云身份证实名认证API的代码:
#include
#include
#include
int main() {
// 创建 HTTP 客户端
web::http::client::http_client client(U("https://netocr.com/verapi/veriden.do"));
// 构建请求内容
web::http::multipart_content content;
content.add(web::http::name(U("img")), web::http::value(U("/9j")));
content.add(web::http::name(U("key")), web::http::value(U("M***********g")));
content.add(web::http::name(U("secret")), web::http::value(U("3***********6")));
content.add(web::http::name(U("typeId")), web::http::value(U("3003")));
content.add(web::http::name(U("trueName")), web::http::value(U("陈**")));
content.add(web::http::name(U("idenNo")), web::http::value(U("13***************3")));
content.add(web::http::name(U("format")), web::http::value(U("json")));
// 创建 HTTP 请求
web::http::http_request request(web::http::methods::POST);
request.headers().set_content_type(U("multipart/form-data; boundary=") + content.boundary());
request.set_body(content);
// 发送请求并获取响应
web::http::http_response response = client.request(request).get();
// 确保请求成功
if (response.status_code() == web::http::status_codes::OK) {
// 读取响应内容
std::wstring responseString = response.extract_string().get();
std::wcout << "Response: " << responseString << std::endl;
} else {
std::cerr << "Request failed with status code " << response.status_code() << std::endl;
}
return 0;
}
标签:web,http,name,接口,认证,content,add,实名,value
From: https://blog.csdn.net/weixin_49544544/article/details/136806987