This commit is contained in:
keita
2021-02-18 11:38:41 +09:00
parent e45fc37c12
commit 998dcfb9a7
6 changed files with 14 additions and 14 deletions
+5 -5
View File
@@ -3,13 +3,13 @@
#include <fstream>
#include <string>
namespace CocoaTweet::OAuth{
Key Key::fromJsonFile(const std::string _jsonFile){
namespace CocoaTweet::OAuth {
Key Key::fromJsonFile(const std::string _jsonFile) {
std::ifstream ifs(_jsonFile);
std::string str((std::istreambuf_iterator<char>(ifs)), std::istreambuf_iterator<char>());
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
+1 -2
View File
@@ -42,8 +42,7 @@ std::map<std::string, std::string> OAuth1::signature(
std::cout << "significate base : " << significateBase << std::endl;
std::cout << "hmac-sha1 : " << k64Sha1 << std::endl;
auto ret = std::map<std::string, std::string>{
{"oauth_signature", k64Sha1}};
auto ret = std::map<std::string, std::string>{{"oauth_signature", k64Sha1}};
return ret;
}
+2 -1
View File
@@ -11,7 +11,8 @@ std::string urlEncode(const std::string& _str) {
(c == '.' || (c == '_') || (c == '-' || (c == '~')))) {
out << c;
} 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));
}
}