整形
This commit is contained in:
@@ -18,7 +18,7 @@ size_t postInterface::curlCallback_(char* _ptr, size_t _size, size_t _nmemb,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void postInterface::process(std::weak_ptr<CocoaTweet::OAuth::OAuth1> _oauth,
|
void postInterface::process(std::weak_ptr<CocoaTweet::OAuth::OAuth1> _oauth,
|
||||||
std::function<void(std::string)> _callback) {
|
std::function<void(std::string)> _callback) {
|
||||||
// エンドポイントへのパラメータにOAuthパラメータを付加して署名作成
|
// エンドポイントへのパラメータにOAuthパラメータを付加して署名作成
|
||||||
auto oauth = _oauth.lock();
|
auto oauth = _oauth.lock();
|
||||||
auto oauthParam = oauth->oauthParam();
|
auto oauthParam = oauth->oauthParam();
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ namespace CocoaTweet::API::Interface {
|
|||||||
class postInterface {
|
class postInterface {
|
||||||
public:
|
public:
|
||||||
void process(std::weak_ptr<CocoaTweet::OAuth::OAuth1> _oauth,
|
void process(std::weak_ptr<CocoaTweet::OAuth::OAuth1> _oauth,
|
||||||
std::function<void(std::string)> _callback);
|
std::function<void(std::string)> _callback);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
std::weak_ptr<CocoaTweet::OAuth::OAuth1> oauth_;
|
std::weak_ptr<CocoaTweet::OAuth::OAuth1> oauth_;
|
||||||
|
|||||||
@@ -3,13 +3,13 @@
|
|||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
namespace CocoaTweet::OAuth{
|
namespace CocoaTweet::OAuth {
|
||||||
Key Key::fromJsonFile(const std::string _jsonFile){
|
Key Key::fromJsonFile(const std::string _jsonFile) {
|
||||||
|
std::ifstream ifs(_jsonFile);
|
||||||
std::ifstream ifs(_jsonFile);
|
std::string str((std::istreambuf_iterator<char>(ifs)), std::istreambuf_iterator<char>());
|
||||||
std::string str((std::istreambuf_iterator<char>(ifs)), std::istreambuf_iterator<char>());
|
|
||||||
|
|
||||||
auto j = nlohmann::json::parse(str);
|
auto j = nlohmann::json::parse(str);
|
||||||
return Key(j["consumer_key"], j["consumer_secret"], j["access_token"], j["access_token_secret"]);
|
return Key(j["consumer_key"], j["consumer_secret"], j["access_token"],
|
||||||
}
|
j["access_token_secret"]);
|
||||||
}
|
}
|
||||||
|
} // namespace CocoaTweet::OAuth
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ public:
|
|||||||
{"oauth_token", accessTokenSecret_}};
|
{"oauth_token", accessTokenSecret_}};
|
||||||
}
|
}
|
||||||
|
|
||||||
static Key fromJsonFile(const std::string _jsonFile);
|
static Key fromJsonFile(const std::string _jsonFile);
|
||||||
};
|
};
|
||||||
} // namespace CocoaTweet::OAuth
|
} // namespace CocoaTweet::OAuth
|
||||||
|
|
||||||
|
|||||||
@@ -42,8 +42,7 @@ std::map<std::string, std::string> OAuth1::signature(
|
|||||||
std::cout << "significate base : " << significateBase << std::endl;
|
std::cout << "significate base : " << significateBase << std::endl;
|
||||||
std::cout << "hmac-sha1 : " << k64Sha1 << std::endl;
|
std::cout << "hmac-sha1 : " << k64Sha1 << std::endl;
|
||||||
|
|
||||||
auto ret = std::map<std::string, std::string>{
|
auto ret = std::map<std::string, std::string>{{"oauth_signature", k64Sha1}};
|
||||||
{"oauth_signature", k64Sha1}};
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,8 @@ std::string urlEncode(const std::string& _str) {
|
|||||||
(c == '.' || (c == '_') || (c == '-' || (c == '~')))) {
|
(c == '.' || (c == '_') || (c == '-' || (c == '~')))) {
|
||||||
out << c;
|
out << c;
|
||||||
} else {
|
} else {
|
||||||
out << '%' << std::setw(2) << std::setfill('0') << std::hex << std::uppercase << (0xFF & static_cast<int>(c));
|
out << '%' << std::setw(2) << std::setfill('0') << std::hex << std::uppercase
|
||||||
|
<< (0xFF & static_cast<int>(c));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user