整形
This commit is contained in:
@@ -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
|
||||||
|
|||||||
@@ -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