libcurl操作digu的例子
获取用户信息:
curl_easy_setopt(curl, CURLOPT_URL, "http://api.minicloud.com.cn/statuses/friends_timeline.format");
//设置回调函数
curl_easy_setopt(curl,CURLOPT_WRITEFUNCTION,function);
//设置文件句柄
curl_easy_setopt(curl,CURLOPT_WRITEDATA,f);
/* Now specify the POST data */
curl_easy_setopt(curl, CURLOPT_USERPWD , "user:password" );
/* Perform the request, res will get the return code */
res = curl_easy_perform(curl);
推送消息:
curl_easy_setopt(curl, CURLOPT_URL, "http://api.minicloud.com.cn/statuses/update.format");
////设置回调函数
// curl_easy_setopt(curl,CURLOPT_WRITEFUNCTION,function);
////设置文件句柄
//curl_easy_setopt(curl,CURLOPT_WRITEDATA,f);
/* Now specify the POST data */
curl_easy_setopt(curl, CURLOPT_USERPWD , "user:password" );
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, "content=要发的消息");
//这是post的参数,需要什么填什么吧
/* Perform the request, res will get the return code */
res = curl_easy_perform(curl);
/* always cleanup */
curl_easy_cleanup(curl);
另附上一篇libcurl的好文:
http://blog.chinaunix.net/u3/111961/showart_2291335.html