I use cocos2d-x 2.0 ,
void HelloWorld::dohttps(const char url,const chardata){
CURL curl;
CURLcode res;
int result = 1;
string buffer;
curl_global_init;
curl = curl_easy_init;
if
{
curl_slistplist = curl_slist_append(NULL, “Content-Type: text/xml;charset=UTF-8”);
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, plist);
res=curl_easy_setopt( curl, CURLOPT_URL, url );
//设定为不验证证书和host
res=curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 1);
if(res!=CURLE_OK)
{
return ;
}
res=curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 2);
if(res!=CURLE_OK)
{
return ;
}
//res=curl_easy_setopt(curl,CURLOPT_HEADER,1);
//res=curl_easy_setopt(curl,CURLOPT_CAINFO,pCACertFile);
//res=curl_easy_setopt(curl, CURLOPT_POST, 1);//启用POST提交
//res=curl_easy_setopt(curl, CURLOPT_POSTFIELDS, data);
res=curl_easy_setopt( curl, CURLOPT_FOLLOWLOCATION, 1L );
res=curl_easy_setopt( curl, CURLOPT_WRITEFUNCTION, HelloWorld::writer );
res=curl_easy_setopt( curl, CURLOPT_WRITEDATA, &buffer );
res=curl_easy_setopt(curl, CURLOPT_VERBOSE, 1); // Used to debug
//curl_easy_setopt(curl, CURLOPT_STDERR, pFILE_error_info); // save error info in the file or stderr
//curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, error_buff); // error_buff used to save error info
//res=curl_easy_setopt(curl, CURLOPT_RETURNTRANSFER, 1);
res = curl_easy_perform( curl );
curl_easy_cleanup( curl );
std::string result=buffer.c_str();
CCLog(“gggggggggg=%s”,result);
}
}
// do test
std::string httpsurl=“https://login.taobao.com/member/login.jhtml”;
dohttps(httpsurl.c_str(),httpsdata.c_str());
//but return CURLE_UNSUPPORTED_PROTOCOL,I don’t know why?
is cocos2d-x 2.0 support https?
is here someone help me?