实名认证API实时联网核验个人身份信息与所持身份证件人员的一致性,可满足不同应用场景的不同实名认证需求,如身份证号+姓名核验、身份证号+姓名+人像核验、身份证号+姓名+证件人像+现场人像核验等,有助于推动诚信网络环境建设,降低利用网络进行违法犯罪的可能性,防止纠纷和诈骗,确保消费者权益不受侵害。
以下是C++语言调用翔云身份实名认证API的代码:
#include
#include
#include
int main() {
// 创建 HTTP 客户端
web::http::client::http_client client(U("https://netocr.com/verapi/veridenOrd.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("3013")));
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,示例,C++,content,add,实名,value
From: https://www.cnblogs.com/netocr/p/18058729