您的位置:首页 > 其它

用c写了一个向sohu微博发信息的程序,不知为什么发中文时总是乱码?

2011-12-13 16:26 691 查看
用c写了一个向sohu微博发信息的程序,不知为什么发中文时总是乱码?

int CWeiboSohu::SendMsg(char *szMsg)

{

//

////////////////////////////////////////////////////////////////

char *pCode = FormUrlEncode(szMsg);

char* pUtf8 = MbcsToUtf8(pCode);

////////////////////////////////////////////////////////////////

char szUrl[1024] = "http://api.t.sohu.com/statuses/update.json?source=UGKujfSYomAjKkIcgbbu&status=";

strcat(szUrl, pUtf8); //hiiii111222";

//

CURL *curl;

CURLcode res;

//

curl = curl_easy_init();

//

if(curl){

//

curl_easy_setopt(curl, CURLOPT_POST, 1 );

curl_easy_setopt(curl, CURLOPT_URL, "http://api.t.sohu.com/statuses/update.json");

//curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);

curl_easy_setopt(curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);

curl_easy_setopt(curl, CURLOPT_USERPWD, "Name:Password");

//

curl_easy_setopt(curl, CURLOPT_POSTFIELDS, szUrl);

curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, strlen(szUrl));

//

res = curl_easy_perform(curl);

// always cleanup

curl_easy_cleanup(curl);

}

return 0;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐