コードヲチョットソウジシタ

This commit is contained in:
keita
2021-02-18 18:45:10 +09:00
parent 106da593c5
commit a62d0fe7ff
4 changed files with 16 additions and 37 deletions
+1 -11
View File
@@ -40,13 +40,6 @@ void postInterface::process(std::weak_ptr<CocoaTweet::OAuth::OAuth1> _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, "&");
}
std::cout << "request Body -> " << requestBody << std::endl;
@@ -67,15 +60,13 @@ void postInterface::process(std::weak_ptr<CocoaTweet::OAuth::OAuth1> _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_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<CocoaTweet::OAuth::OAuth1> _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);
+1 -2
View File
@@ -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";
}
+1 -10
View File
@@ -28,16 +28,7 @@ std::map<std::string, std::string> 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<std::string>(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, "&");
auto significateKey = key().consumerSecret() + "&" + key().accessTokenSecret();
-1
View File
@@ -31,6 +31,5 @@ std::string join(const std::vector<std::string> _vec, const std::string& _delim)
}
return str;
}
} // namespace CocoaTweet::Util