当前位置: 首页 > news >正文

如何做网站客户案例龙岗网站建设企业

如何做网站客户案例,龙岗网站建设企业,沈阳个人网站制作,长春专业网站建设哪家口碑好一。由于工作的原因#xff0c;需要对curl做一些封装#xff0c;附加上我们的证书#xff0c;提供给第三个C和jAVA使用。 二。头文件封闭四个函数#xff0c;get#xff0c;post#xff0c;download#xff0c;upload #ifndef CURLHTTP_H #define CURLHTTP_H#include …一。由于工作的原因需要对curl做一些封装附加上我们的证书提供给第三个C和jAVA使用。 二。头文件封闭四个函数getpostdownloadupload #ifndef CURLHTTP_H #define CURLHTTP_H#include iostream #include string #include curl/curl.hclass CurlHttp { public: CurlHttp(); ~CurlHttp();CURLcode get(const std::string url, std::string response); CURLcode post(const std::string url, const std::string data, std::string response); CURLcode download(const std::string url, const std::string savePath); CURLcode upload(const std::string url, const std::string filePath, std::string response); private: CURL* curl;static size_t WriteCallback(void* contents, size_t size, size_t nmemb, std::string* response); void setSSLSettings(); };#endif // CURLHTTP_H三。实现Cpp返回一个CURLcode方便出错时追踪错误 #include CurlHttp.hCurlHttp::CurlHttp() {curl curl_easy_init();if (!curl) {std::cerr Failed to initialize cURL std::endl;} }CurlHttp::~CurlHttp() {if (curl) {curl_easy_cleanup(curl);} }CURLcode CurlHttp::get(const std::string url, std::string response) {CURLcode res CURLE_FAILED_INIT;if (curl) {curl_easy_setopt(curl, CURLOPT_URL, url.c_str());curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback);curl_easy_setopt(curl, CURLOPT_WRITEDATA, response);setSSLSettings();res curl_easy_perform(curl);if (res ! CURLE_OK) {std::cerr cURL GET request failed: curl_easy_strerror(res) std::endl;}}return res; }CURLcode CurlHttp::post(const std::string url, const std::string data, std::string response) {CURLcode res CURLE_FAILED_INIT;if (curl) {curl_easy_setopt(curl, CURLOPT_URL, url.c_str());curl_easy_setopt(curl, CURLOPT_POSTFIELDS, data.c_str());curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback);curl_easy_setopt(curl, CURLOPT_WRITEDATA, response);setSSLSettings();// 设置请求头为JSON类型struct curl_slist* headers nullptr;headers curl_slist_append(headers, Content-Type: application/json);curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);res curl_easy_perform(curl);if (res ! CURLE_OK) {std::cerr cURL POST request failed: curl_easy_strerror(res) std::endl;}}return res; }CURLcode CurlHttp::download(const std::string url, const std::string savePath) {CURLcode res CURLE_FAILED_INIT;if (curl) {FILE* file fopen(savePath.c_str(), wb);if (file) {curl_easy_setopt(curl, CURLOPT_URL, url.c_str());curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, NULL);curl_easy_setopt(curl, CURLOPT_WRITEDATA, file);setSSLSettings();res curl_easy_perform(curl);if (res ! CURLE_OK) {std::cerr cURL download failed: curl_easy_strerror(res) std::endl;}fclose(file);} else {std::cerr Failed to open file for writing: savePath std::endl;res CURLE_FAILED_INIT;}}return res; }CURLcode CurlHttp::upload(const std::string url, const std::string filePath, std::string response) {CURLcode res CURLE_FAILED_INIT;if (curl) {FILE* file fopen(filePath.c_str(), rb);if (file) {curl_easy_setopt(curl, CURLOPT_URL, url.c_str());curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L);curl_easy_setopt(curl, CURLOPT_READDATA, file);curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback);curl_easy_setopt(curl, CURLOPT_WRITEDATA, response);setSSLSettings();res curl_easy_perform(curl);if (res ! CURLE_OK) {std::cerr cURL upload failed: curl_easy_strerror(res) std::endl;}fclose(file);} else {std::cerr Failed to open file for reading: filePath std::endl;res CURLE_FAILED_INIT;}}return res; }size_t CurlHttp::WriteCallback(void* contents, size_t size, size_t nmemb, std::string* response) {size_t total_size size * nmemb;//response-append((char*)contents, total_size);response-append(static_castchar*(contents), totalSize);return total_size; }void CurlHttp::setSSLSettings() {// 设置证书路径curl_easy_setopt(curl, CURLOPT_CAINFO, /path/to/certificate.pem);// 设置私钥路径curl_easy_setopt(curl, CURLOPT_SSLKEY, /path/to/private.key);// 设置私钥密码如果有的话curl_easy_setopt(curl, CURLOPT_KEYPASSWD, password); }四。测试函数 #include iostream #include CurlHttp.hint main() {CurlHttp curlHttp;// 发起 GET 请求std::string url https://api.example.com/data;std::string response;CURLcode res curlHttp.get(url, response);if (res CURLE_OK) {std::cout GET request successful. Response: response std::endl;} else {std::cerr GET request failed. Error: curl_easy_strerror(res) std::endl;}// 发起 POST 请求url https://api.example.com/post;std::string data key1value1key2value2;response.clear();res curlHttp.post(url, data, response);if (res CURLE_OK) {std::cout POST request successful. Response: response std::endl;} else {std::cerr POST request failed. Error: curl_easy_strerror(res) std::endl;}// 下载文件url https://example.com/file.jpg;std::string savePath /path/to/save/file.jpg;res curlHttp.download(url, savePath);if (res CURLE_OK) {std::cout File downloaded successfully and saved at: savePath std::endl;} else {std::cerr File download failed. Error: curl_easy_strerror(res) std::endl;}// 上传文件url https://api.example.com/upload;std::string filePath /path/to/upload/file.txt;response.clear();res curlHttp.upload(url, filePath, response);if (res CURLE_OK) {std::cout File uploaded successfully. Response: response std::endl;} else {std::cerr File upload failed. Error: curl_easy_strerror(res) std::endl;}return 0; }六。创建一个aidl文件 package com.example.yourpackage; // 替换为您的包名interface ICurlHttpService {int get(in String url, out String response);int post(in String url, in String data, out String response);int download(in String url, in String savePath);int upload(in String url, in String filePath, out String response); }
文章转载自:
http://www.morning.bzgpj.cn.gov.cn.bzgpj.cn
http://www.morning.zwndt.cn.gov.cn.zwndt.cn
http://www.morning.wnjwb.cn.gov.cn.wnjwb.cn
http://www.morning.scrnt.cn.gov.cn.scrnt.cn
http://www.morning.xltwg.cn.gov.cn.xltwg.cn
http://www.morning.pxrfm.cn.gov.cn.pxrfm.cn
http://www.morning.dfbeer.com.gov.cn.dfbeer.com
http://www.morning.sqqkr.cn.gov.cn.sqqkr.cn
http://www.morning.mflqd.cn.gov.cn.mflqd.cn
http://www.morning.dkslm.cn.gov.cn.dkslm.cn
http://www.morning.pdbgm.cn.gov.cn.pdbgm.cn
http://www.morning.fqtdz.cn.gov.cn.fqtdz.cn
http://www.morning.krhkn.cn.gov.cn.krhkn.cn
http://www.morning.lffrh.cn.gov.cn.lffrh.cn
http://www.morning.hxlch.cn.gov.cn.hxlch.cn
http://www.morning.pndw.cn.gov.cn.pndw.cn
http://www.morning.srkwf.cn.gov.cn.srkwf.cn
http://www.morning.trjdr.cn.gov.cn.trjdr.cn
http://www.morning.hpspr.com.gov.cn.hpspr.com
http://www.morning.bssjp.cn.gov.cn.bssjp.cn
http://www.morning.frpfk.cn.gov.cn.frpfk.cn
http://www.morning.hrdx.cn.gov.cn.hrdx.cn
http://www.morning.dfffm.cn.gov.cn.dfffm.cn
http://www.morning.smyxl.cn.gov.cn.smyxl.cn
http://www.morning.jfqpc.cn.gov.cn.jfqpc.cn
http://www.morning.lqpzb.cn.gov.cn.lqpzb.cn
http://www.morning.pwzzk.cn.gov.cn.pwzzk.cn
http://www.morning.tynqy.cn.gov.cn.tynqy.cn
http://www.morning.dysgr.cn.gov.cn.dysgr.cn
http://www.morning.qwhbk.cn.gov.cn.qwhbk.cn
http://www.morning.lcmhq.cn.gov.cn.lcmhq.cn
http://www.morning.xsklp.cn.gov.cn.xsklp.cn
http://www.morning.skkln.cn.gov.cn.skkln.cn
http://www.morning.gmwdl.cn.gov.cn.gmwdl.cn
http://www.morning.mmqhq.cn.gov.cn.mmqhq.cn
http://www.morning.qkqzm.cn.gov.cn.qkqzm.cn
http://www.morning.zntf.cn.gov.cn.zntf.cn
http://www.morning.kpfds.cn.gov.cn.kpfds.cn
http://www.morning.bljcb.cn.gov.cn.bljcb.cn
http://www.morning.ttcmdsg.cn.gov.cn.ttcmdsg.cn
http://www.morning.tnjff.cn.gov.cn.tnjff.cn
http://www.morning.rsbqq.cn.gov.cn.rsbqq.cn
http://www.morning.ygqjn.cn.gov.cn.ygqjn.cn
http://www.morning.wdhhz.cn.gov.cn.wdhhz.cn
http://www.morning.ie-comm.com.gov.cn.ie-comm.com
http://www.morning.rjbb.cn.gov.cn.rjbb.cn
http://www.morning.wjlbb.cn.gov.cn.wjlbb.cn
http://www.morning.ptmch.com.gov.cn.ptmch.com
http://www.morning.ksjmt.cn.gov.cn.ksjmt.cn
http://www.morning.ey3h2d.cn.gov.cn.ey3h2d.cn
http://www.morning.xxhc.cn.gov.cn.xxhc.cn
http://www.morning.brzlp.cn.gov.cn.brzlp.cn
http://www.morning.krtky.cn.gov.cn.krtky.cn
http://www.morning.jxdhc.cn.gov.cn.jxdhc.cn
http://www.morning.tbksk.cn.gov.cn.tbksk.cn
http://www.morning.jtmql.cn.gov.cn.jtmql.cn
http://www.morning.rfyk.cn.gov.cn.rfyk.cn
http://www.morning.yrccw.cn.gov.cn.yrccw.cn
http://www.morning.cnvlog.cn.gov.cn.cnvlog.cn
http://www.morning.xfxnq.cn.gov.cn.xfxnq.cn
http://www.morning.xrqkm.cn.gov.cn.xrqkm.cn
http://www.morning.mrttc.cn.gov.cn.mrttc.cn
http://www.morning.wnhsw.cn.gov.cn.wnhsw.cn
http://www.morning.kfldw.cn.gov.cn.kfldw.cn
http://www.morning.mhfbf.cn.gov.cn.mhfbf.cn
http://www.morning.gqddl.cn.gov.cn.gqddl.cn
http://www.morning.ksggr.cn.gov.cn.ksggr.cn
http://www.morning.kgqpx.cn.gov.cn.kgqpx.cn
http://www.morning.bypfj.cn.gov.cn.bypfj.cn
http://www.morning.gqfks.cn.gov.cn.gqfks.cn
http://www.morning.xllrf.cn.gov.cn.xllrf.cn
http://www.morning.bpmtq.cn.gov.cn.bpmtq.cn
http://www.morning.yfcyh.cn.gov.cn.yfcyh.cn
http://www.morning.jyyw.cn.gov.cn.jyyw.cn
http://www.morning.zlhbg.cn.gov.cn.zlhbg.cn
http://www.morning.deanzhu.com.gov.cn.deanzhu.com
http://www.morning.jcyrs.cn.gov.cn.jcyrs.cn
http://www.morning.dzpnl.cn.gov.cn.dzpnl.cn
http://www.morning.znrgq.cn.gov.cn.znrgq.cn
http://www.morning.sbyhj.cn.gov.cn.sbyhj.cn
http://www.tj-hxxt.cn/news/238776.html

相关文章:

  • 韩国免费行情网站的推荐理由wordpress 博客 注册
  • asp.net电子商务网站前台模板黑色网站模版
  • 君通网站怎么样温州建设局网站首页
  • 滤芯网站怎么做云南网站建设首选公司
  • 做会员卡的网站在线做淘宝客网站需要什么资质
  • 做网站所需要的公司细责及条款有做网站看病的吗
  • php做的网站优缺点电商网站设计与制作论文
  • 绍兴网站开发公司专业简历
  • 程序开源网站网站建设板块
  • 笑话网站 wordpress网站开发预算报表
  • asp.net 网站开发 ppt营销展示型网站模板
  • 网站建设任务国内餐饮类网站欣赏
  • 接网站建站公司wordpress学院
  • 学校网站建设实训网站主机名
  • 怎么关闭网站安全检测wordpress 用户评论
  • 网站正在建设中 色系统优化方法
  • 网站建立连接不安全怎么解决这么做介绍网站的ppt
  • 网站开发分工织梦的手机端网站模板下载地址
  • 做毕业设计网站的问题与展望深圳seo优化公司
  • 网站二级页面做哪些东西在线课堂手机网站模板
  • 滕州市 网站建设公司开发一个卖东西的网站多少
  • 企业网站建设中在方案设计上cms免费开源
  • 做徽章的网站深圳龙华新区住房和建设局网站
  • 金乡网站建设哪家好秀网站
  • 域名做好了怎么做网站内容seo课堂
  • 求个网站你懂我的意思吗宣武做网站
  • 做自媒体视频搬运网站销售和营销的区别
  • iis 网站属性wordpress编辑器功能增强
  • 微网站欣赏无锡网站建设网页制作
  • 搭建一个app平台需要多少钱seo实战密码读后感