您的位置:首页 > 其它

百度API—身份证查询

2015-10-26 14:53 363 查看
直接上代码:

#include <afxinet.h>
void CTestJsonDlg::OnBnClickedButton1()
{
//使用百度api获取数据-----------------------------------------------------------------
char buf[1000] = { 0 };
CString strIDCard;
CInternetSession session;
CHttpFile* file = NULL; int nRead;
file = (CHttpFile *)session.OpenURL(_T("http://apistore.baidu.com/microservice/icardinfo?id=xxxxxxxxxxxxxxxxxx"));//id为身份证号码,需要自己输入
if (NULL != file){
//Do something here with the web request
//Clean up the file here to avoid a memory leak!!!!!!!
while ((nRead = file->Read(buf, sizeof(buf))) > 0){
strIDCard = buf;
}
GetDlgItem(IDC_ID_CARD)->SetWindowText(strIDCard );
file->Close();
delete file;
}
session.Close();
}


解析获取的json字符串见下篇文章。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  百度API