libcurlのリクエストボディに正常にパラメータを追加できた(#47)

This commit is contained in:
keita
2021-02-17 10:21:30 +09:00
parent 6eb90553d1
commit 3863349826
+3 -4
View File
@@ -67,14 +67,13 @@ void Update::process(std::weak_ptr<CocoaTweet::OAuth::OAuth1> _oauth,
CURLcode res; CURLcode res;
std::string rcv; std::string rcv;
curl = curl_easy_init(); curl = curl_easy_init();
url_ = url_ + "?status=" + status_; url_ = url_;// + "?status=" + status_;
std::cout << "URL : " << url_ << std::endl; std::cout << "URL : " << url_ << std::endl;
if (curl) { if (curl) {
curl_easy_setopt(curl, CURLOPT_URL, url_.c_str()); curl_easy_setopt(curl, CURLOPT_URL, url_.c_str());
curl_easy_setopt(curl, CURLOPT_POST, 1); curl_easy_setopt(curl, CURLOPT_POST, 1);
// curl_easy_setopt(curl, CURLOPT_POSTFIELDS, requestBody); curl_easy_setopt(curl, CURLOPT_POSTFIELDS, requestBody.c_str());
// curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, requestBody.length()); curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, requestBody.length());
curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, 0);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, curlCallback_); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, curlCallback_);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, (std::string*)&rcv); curl_easy_setopt(curl, CURLOPT_WRITEDATA, (std::string*)&rcv);
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);