-
资源已经上传,本人通过vs2015搭建了c++版的http请求,其中调用的的libcurl库实现的http请求,同时满足json格式请求方式,资源下载以后可以直接运行。
-
项目的结构如下图所示:
-
项目配置curl库的目录如下图所示:
-
实现pos方式的http请求如下代码:
// libcurlPostJson.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
#include <sstream>
//json
#include "json/json.h"
using namespace std;
//http://blog.csdn.net/wyansai/article/details/50764315
wstring AsciiToUnicode(const string& str)
{
// 预算-缓冲区中宽字节的长度
int unicodeLen = MultiByteToWideChar(CP_ACP, 0, str.c_str(), -1, nullptr, 0);
// 给指向缓冲区的指针变量分配内存
wchar_t *pUnicode = (wchar_t*)malloc(