In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
Scene
Multipart/form-data is the way browsers upload files with forms. The most common scenario is that when writing an email, an attachment is added to the message, usually using a form, that is, uploading it to the server in multipart/form-data format. The Http server defines the format of uploaded data. The API address is http://10.10.10.10:80/restful/personInfo. The parameters are as follows:
Msg: {
"name": "fengyuzaitu"
"data": {
"id": "9191"
}
"sex": "1"
"type": "worker"
}
Code
Int PostHttpFormDataByLibCurl ()
{
Json::Value root
Root ["type"] = "worker"
Root ["sex"] = "1"
Root ["name"] = "fengyuzaitu"
Json::Value data
Data ["id"] = "9191"
Root ["data"] = data
Std::string strPostData = root.toStyledString ()
CURL * pCurlHandle = curl_easy_init ()
Std::string strResponseData
Curl_easy_setopt (pCurlHandle, CURLOPT_CUSTOMREQUEST, "POST")
Curl_easy_setopt (pCurlHandle, CURLOPT_URL, "http://10.10.10.10:80/restful/personInfo");"
Curl_easy_setopt (pCurlHandle, CURLOPT_WRITEFUNCTION, WriteResponseBody); / / set callback function
Curl_easy_setopt (pCurlHandle, CURLOPT_WRITEDATA, & strResponseData); / / set the parameters of the callback function to get feedback information
Struct curl_httppost * pFormPost = 0
Struct curl_httppost * pLastPtrFormPost = 0
Curl_formadd (& pFormPost, & pLastPtrFormPost, CURLFORM_COPYNAME, "msg", CURLFORM_COPYCONTENTS, strPostData.c_str (), CURLFORM_END)
Curl_easy_setopt (pCurlHandle, CURLOPT_HTTPPOST, pFormPost)
CURLcode nRet = curl_easy_perform (pCurlHandle)
If (0 = = nRet)
{
Std::cout
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.