18,356
社区成员
发帖
与我相关
我的任务
分享
CURL *curl;
CURLcode code;
curl_global_init(CURL_GLOBAL_ALL);
curl = curl_easy_init();
//https 访问专用:start
#ifdef SKIP_PEER_VERIFICATION
//跳过服务器SSL验证,不使用CA证书
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
#endif
#ifdef SKIP_HOSTNAME_VERFICATION
//验证服务器端发送的证书,默认是 2(高),1(中),0(禁用)
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L);
#endif
//https 访问专用:end
std::string url = "https://www.xxx.com/user/login";
curl_easy_setopt(curl, CURLOPT_URL,url.c_str());
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, "nick=xxx&pwd=xxx");
code = curl_easy_perform(curl);
if(CURLE_OK == code)
{
printf("Login Successful!\n");
}
else
{
printf("Login Fail!\n");
}
curl_global_init(CURL_GLOBAL_ALL);
m_A_curl = curl_easy_init();
//https 访问专用:start
#ifdef SKIP_PEER_VERIFICATION
//跳过服务器SSL验证,不使用CA证书
curl_easy_setopt(m_A_curl, CURLOPT_SSL_VERIFYPEER, 0L);
#endif
#ifdef SKIP_HOSTNAME_VERFICATION
//验证服务器端发送的证书,默认是 2(高),1(中),0(禁用)
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L);
#endif
//https 访问专用:end
curl_easy_setopt(m_A_curl,CURLOPT_URL,"https://www.xxx.com/user/login");
curl_easy_setopt(m_A_curl,CURLOPT_POSTFIELDS,"nick=xxx&pwd=xxx");
m_A_code = curl_easy_perform(m_A_curl);
if(CURLE_OK == m_A_code)
{
DisplayMsg(_T("login success!\n"));
}
else
{
DisplayMsg(_T("login Fail!\n"));
}