コードヲチョットソウジシタ
This commit is contained in:
@@ -40,14 +40,7 @@ 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, "&");
|
||||
requestBody = CocoaTweet::Util::join(tmp, "&");
|
||||
}
|
||||
std::cout << "request Body -> " << requestBody << std::endl;
|
||||
|
||||
@@ -58,7 +51,7 @@ void postInterface::process(std::weak_ptr<CocoaTweet::OAuth::OAuth1> _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<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_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,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";
|
||||
}
|
||||
|
||||
@@ -28,17 +28,8 @@ 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, "&");
|
||||
|
||||
std::string query = CocoaTweet::Util::join(tmp, "&");
|
||||
|
||||
auto significateKey = key().consumerSecret() + "&" + key().accessTokenSecret();
|
||||
auto significateBase = _method + "&" + CocoaTweet::Util::urlEncode(_url) + "&" +
|
||||
|
||||
@@ -20,17 +20,16 @@ std::string urlEncode(const std::string& _str) {
|
||||
}
|
||||
|
||||
std::string join(const std::vector<std::string> _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
|
||||
|
||||
Reference in New Issue
Block a user