weixin_37839679 2017-03-09 22:24 采纳率: 0%
浏览 1956

C++环境,如何保存http的post回应消息,post部分使用了curl库

函数主体如下:

#include<curl\curl.h>
int main()
{
CURL *hnd = curl_easy_init();

    curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
    curl_easy_setopt(hnd, CURLOPT_URL, "api.thingspeak.com/talkbacks/14072/commands/execute.json");

    struct curl_slist *headers = NULL;
    headers = curl_slist_append(headers, "content-type: application/x-www-form-urlencoded");
    headers = curl_slist_append(headers, "postman-token: 4fdca9ae-9b34-6525-cca4-3f59776fe95e");
    headers = curl_slist_append(headers, "cache-control: no-cache");
    curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
    curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "api_key=Q7S2VY3XG1KDLMNF");

    CURLcode ret = curl_easy_perform(hnd);


}

图片是运行结果,一个JSON对象,即回应信息,想问怎么保存下这个信息。求大神帮助。

图片说明

  • 写回答

4条回答 默认 最新

  • threenewbee 2017-03-09 23:28
    关注

    你说的保存是什么意思?是把返回值写入文本文件?
    http://www.runoob.com/cprogramming/c-file-io.html

    评论

报告相同问题?

悬赏问题

  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算
  • ¥15 java如何提取出pdf里的文字?