使用libcurl的包装库cpr发起http请求
cpr GitHub地址https://github.com/whoshuu/cpr
简单示例:cpr_http_request.cpp
#include <iostream>
#include <cpr/cpr.h>
int main()
{
std::string requestAddress("https://api.eyekey.com/face/Check/checking");
std::string requestParams("app_id=f89ae61fd63d4a63842277e9144a6bd2&app_key=af1cd33549c54b27ae24aeb041865da2&url=http%3A%2F%2Fpicview01.baomihua.com%2Fphotos%2F20120713%2Fm_14_634778197959062500_40614445.jpg");
std::cout << "GET Sample:" << std::endl;
const cpr::Response &responseForGet = cpr::Get(cpr::Url(requestAddress.append("?" + requestParams)));
std::cout << '\t' << responseForGet.status_code << std::endl;
std::cout << '\t' << responseForGet.text << std::endl;
std::cout << "POST Sample:" << std::endl;
cpr::Multipart multipart{ { "app_id", "f89ae61fd63d4a63842277e9144a6bd2" }, { "app_key", "af1cd33549c54b27ae24aeb041865da2" }, {"url", "https://gss1.bdstatic.com/9vo3dSag_xI4khGkpoWK1HF6hhy/baike/w%3D268%3Bg%3D0/sign=18bb0cc2dd1373f0f53f68999c342cc6/caef76094b36acafe725024570d98d1000e99c46.jpg"} };
const cpr::Response &responseForPost = cpr::Post(cpr::Url(requestAddress), multipart);
std::cout << '\t' << responseForPost.status_code << std::endl;
std::cout << '\t' << responseForPost.text << std::endl;
std::system("pause");
return ;
}
使用libcurl的包装库cpr发起http请求的更多相关文章
- C#发起Http请求,调用接口
//方法1. Post 异步请求,普通的异步请求,传输普通的字符串等,对于有html代码的字段值的传输支持不好,如果需要传输html,二进制等数据的传输,请使用下面第二个方法,即使用UploadDat ...
- libcurl发起post请求时间延迟问题。except为空即可
最近在做团购酒店APP分享到qzone功能,使用libcurl访问qzone的分享cgi接口,酒店分享信息以POST方式传输,在测试的时候发现分享接口平均有2s的延迟,这延迟也太大了吧,于是乎问了空间 ...
- 大概看了一天python request源码。写下python requests库发送 get,post请求大概过程。
python requests库发送请求时,比如get请求,大概过程. 一.发起get请求过程:调用requests.get(url,**kwargs)-->request('get', url ...
- php 使用curl发起https请求
今天一个同事反映,使用curl发起https请求的时候报错:“SSL certificate problem, verify that the CA cert is OK. Details: erro ...
- openresty开发系列29--openresty中发起http请求
openresty开发系列29--openresty中发起http请求 有些场景是需要nginx在进行请求转发 用户浏览器请求url访问到nginx服务器,但此请求业务需要再次请求其他业务:如用户请求 ...
- Node.js模拟发起http请求从异步转同步的5种方法
使用Node.js模拟发起http请求很常用的,但是由于Node模块(原生和第三方库)提供里面的方法都是异步,对于很多场景下应用很麻烦,不如同步来的方便.下面总结了几个常见的库API从异步转同步的几种 ...
- C# 应用 - 使用 HttpWebRequest 发起 Http 请求
helper 类封装 调用 1. 引用的库类 \Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6\System.dll Syste ...
- C# 应用 - 使用 HttpClient 发起 Http 请求
1. 需要的库类 \Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\System.Net.Http.dll System.N ...
- C# 应用 - 使用 WebClient 发起 Http 请求
1. 需要的库类 \Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\System.dll System.Net.WebCli ...
随机推荐
- 11g自动分区超过最大限制
公司业务系统一张表按时间每天分区 写入数据时报错:ORA-14300: 分区关键字映射到超出允许的最大分区数的分区 ORA-14300: partitioning key maps to a part ...
- 七牛云杜江华:让云 + AI 成为企业服务的标配
12 月 5-6 日,2018 创业邦 100 未来领袖峰会暨创业邦年会(以下简称「创业邦 100 未来领袖峰会」)在北京国家会议中心举行.12 月 5 日下午,七牛云执行副总裁杜江华在企业服务论坛上 ...
- Redis的持久化——RDB
前面说到redis的三大特性:缓存.分布式内存数据库.持久化,所以今天将为大家介绍redis的两种数据持久化技术RDB和AOF, 先介绍RDB吧. 一.RDB是什么? 1.RDB全称redis dat ...
- 【leetcode最短路】818. Race Car
https://leetcode.com/problems/race-car/description/ 1. BFS剪枝 0<=current position<=2*target.为什么 ...
- Spring JdbcTemplate操作小结
Spring 提供了JdbcTemplate 来封装数据库jdbc操作细节: 包括: 数据库连接[打开/关闭] ,异常转义 ,SQL执行 ,查询结果的转换 使用模板方式封装 jdbc数据库操作-固定流 ...
- 跳蚤 BZOJ 4310
跳蚤 [问题描述] 很久很久以前,森林里住着一群跳蚤.一天,跳蚤国王得到了一个神秘的字符串,它想进行研究. 首先,他会把串分成不超过 k 个子串,然后对于每个子串 S,他会从S的所有子串中选择字典序最 ...
- localStorag的一点见解
dot方法对localStorag方法进行键值操作 设值 localStorage.hello = 'world'; localStorage.zhangsan = 'lisi'; 取值: var v ...
- PSEUDO LEAST RECENTLY USED (PLRU) CACHE REPLACEMENT
A multi-way cache system includes multi-way cache storage circuitry, a pseudo least recently used (P ...
- Laravel 控制器的response
public function response(){ //响应json $data = [ 'errCode' => 0, 'errMsg' => 'success', 'data' = ...
- ORACLE RMAN增量备份经典理解
http://blog.itpub.net/26118480/viewspace-1793548/