diff --git a/src/cocoatweet/api/interface/postInterface.cc b/src/cocoatweet/api/interface/postInterface.cc index cd3a883..9298ef1 100644 --- a/src/cocoatweet/api/interface/postInterface.cc +++ b/src/cocoatweet/api/interface/postInterface.cc @@ -40,14 +40,7 @@ void postInterface::process(std::weak_ptr _oauth, for (const auto& [key, value] : bodyParam_) { tmp.push_back(key + "=" + value); } - - /*for(auto v : tmp){ - requestBody += (v + "&"); - } - if(!requestBody.empty()){ - requestBody.pop_back(); - }*/ - requestBody = CocoaTweet::Util::join(tmp, "&"); + requestBody = CocoaTweet::Util::join(tmp, "&"); } std::cout << "request Body -> " << requestBody << std::endl; @@ -58,7 +51,7 @@ void postInterface::process(std::weak_ptr _oauth, for (const auto& [key, value] : oauthParam) { tmp.push_back(key + "=" + CocoaTweet::Util::urlEncode(value)); } - oauthHeader += CocoaTweet::Util::join(tmp, ","); + oauthHeader += CocoaTweet::Util::join(tmp, ","); } std::cout << "OAuth Header -> " << oauthHeader << std::endl; @@ -67,15 +60,13 @@ void postInterface::process(std::weak_ptr _oauth, CURLcode res; std::string rcv; curl = curl_easy_init(); - url_ = url_; // + "?status=" + status_; + url_ = url_; std::cout << "URL : " << url_ << std::endl; if (curl) { curl_easy_setopt(curl, CURLOPT_URL, url_.c_str()); curl_easy_setopt(curl, CURLOPT_POST, 1); - // if(!requestBody.empty()){ - curl_easy_setopt(curl, CURLOPT_POSTFIELDS, requestBody.c_str()); - curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, requestBody.length()); -// } + curl_easy_setopt(curl, CURLOPT_POSTFIELDS, requestBody.c_str()); + curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, requestBody.length()); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, curlCallback_); curl_easy_setopt(curl, CURLOPT_WRITEDATA, (std::string*)&rcv); curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); @@ -83,7 +74,6 @@ void postInterface::process(std::weak_ptr _oauth, struct curl_slist* headers = NULL; // Authorizationをヘッダに追加 headers = curl_slist_append(headers, oauthHeader.c_str()); - // headers = curl_slist_append(headers, "Content-Type: application/x-www-form-urlencoded"); curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers); res = curl_easy_perform(curl); curl_easy_cleanup(curl); diff --git a/src/cocoatweet/api/status/destroy.cc b/src/cocoatweet/api/status/destroy.cc index 51b3c67..d4f7e51 100644 --- a/src/cocoatweet/api/status/destroy.cc +++ b/src/cocoatweet/api/status/destroy.cc @@ -1,8 +1,7 @@ #include "cocoatweet/api/status/destroy.h" namespace CocoaTweet::API::Statuses { -Destroy::Destroy() { -} +Destroy::Destroy() {} void Destroy::id(const std::string _id) { url_ = "https://api.twitter.com/1.1/statuses/destroy/" + _id + ".json"; } diff --git a/src/cocoatweet/oauth/oauth.cc b/src/cocoatweet/oauth/oauth.cc index 4c82f6d..7895229 100644 --- a/src/cocoatweet/oauth/oauth.cc +++ b/src/cocoatweet/oauth/oauth.cc @@ -28,17 +28,8 @@ std::map OAuth1::signature( tmp.push_back(key + "=" + value); std::cout << (key + "=" + value) << std::endl; } - //std::ostringstream os; - //std::copy(tmp.begin(), tmp.end(), std::ostream_iterator(os, "&")); - //std::string query = os.str(); - /*std::string query = ""; - for(auto v : tmp){ - query += (v + "&"); - } - if(!query.empty()){ - query.pop_back(); - }*/ - std::string query = CocoaTweet::Util::join(tmp, "&"); + + std::string query = CocoaTweet::Util::join(tmp, "&"); auto significateKey = key().consumerSecret() + "&" + key().accessTokenSecret(); auto significateBase = _method + "&" + CocoaTweet::Util::urlEncode(_url) + "&" + diff --git a/src/cocoatweet/util/util.cc b/src/cocoatweet/util/util.cc index d8b5df3..022a629 100644 --- a/src/cocoatweet/util/util.cc +++ b/src/cocoatweet/util/util.cc @@ -20,17 +20,16 @@ std::string urlEncode(const std::string& _str) { } std::string join(const std::vector _vec, const std::string& _delim) { - std::string str(""); + std::string str(""); - for(auto v : _vec){ - str += (v + _delim); - } + for (auto v : _vec) { + str += (v + _delim); + } - if(!str.empty()){ - str.pop_back(); - } - - return str; + if (!str.empty()) { + str.pop_back(); + } + return str; } } // namespace CocoaTweet::Util