linux c http接收数据,c语言 Linux CURL发送Http get请求 带参数

我要请求的是

http://fs.ccic365.com/ccic-fs/IOT/updateData.shtml?sn=111111111&dataTime=2019-01-24 10:45:04&dataList=["1_1_25.44;25.00;21.32;134","2_1_8.51","3_1_6","4_1_85.44;25.00","5_1_8.52","6_1_8.53;34","7_1_8.54;16.33;33;22","8_1_8.55"]

转义后

http://fs.ccic365.com/ccic-fs/IOT/updateData.shtml?sn=111111111&dataTime=2019-01-24%2010:45:04&dataList=[%221_1_25.44;25.00;21.32;134%22,%222_1_8.51%22,%223_1_6%22,%224_1_85.44;25.00%22,%225_1_8.52%22,%226_1_8.53;34%22,%227_1_8.54;16.33;33;22%22,%228_1_8.55%22]

/***************************************************************************

* _ _ ____ _

* Project ___| | | | _ \| |

* / __| | | | |_) | |

* | (__| |_| | _ , et al.

*

* This software is licensed as described in the file COPYING, which

* you should have received as part of this distribution. The terms

* are also available at https://curl.haxx.se/docs/copyright.html.

*

* You may opt to use, copy, modify, merge, publish, distribute and/or sell

* copies of the Software, and permit persons to whom the Software is

* furnished to do so, under the terms of the COPYING file.

*

* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY

* KIND, either express or implied.

*

***************************************************************************/

/* * Use getinfo to get content-type after completed transfer.

*

*/

#include #include int main(void)

{

CURL *curl;

CURLcode res;

curl = curl_easy_init();

if(curl) {

curl_easy_setopt(curl, CURLOPT_URL, "http://fs.ccic365.com/ccic-fs/IOT/updateData.shtml?sn=111111111&dataTime=2019-01-24%2010:45:04&dataList=[%221_1_25.44;25.00;21.32;134%22,%222_1_8.51%22,%223_1_6%22,%224_1_85.44;25.00%22,%225_1_8.52%22,%226_1_8.53;34%22,%227_1_8.54;16.33;33;22%22,%228_1_8.55%22]");

res = curl_easy_perform(curl);

if(CURLE_OK == res) {

char *ct;

/* ask for the content-type */

res = curl_easy_getinfo(curl, CURLINFO_CONTENT_TYPE, &ct);

if((CURLE_OK == res) && ct)

printf("We received Content-Type: %s\n", ct);

}

/* always cleanup */

curl_easy_cleanup(curl);

}

return 0;

}

返回正确:

lgl@lgl-virtual-machine:~/Desktop/hello$ ./out

{"数据分析":["主副设备编号:111111111","采集时间:2019-01-24 10:45:04","空气温度:25.44℃","空气湿度:25.00%","二氧化碳浓度:21.32ppm","大气压:134pa","风速:8.51m/s","风向:6","土壤温度:85.44℃","土壤湿度:25.00%","盐分:8.52%","pm2.5:8.53μg/m3","pm10:34μg/m3","当前雨量:8.54ml","昨日雨量:16.33ml","瞬时雨量:33ml","累积雨量:22ml","光照传感器:8.55KLUX"],"status":"1"}We received Content-Type: application/json;charset=UTF-8

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值