format
This commit is contained in:
@@ -142,8 +142,7 @@ void HttpGet::process(std::weak_ptr<CocoaTweet::Authentication::AuthenticatorBas
|
||||
throw CocoaTweet::Exception::CredentialNotVerifiedException(
|
||||
message.get<std::string>().c_str());
|
||||
} else if (error.get<int>() == 348) {
|
||||
throw CocoaTweet::Exception::InvalidateTokenException(
|
||||
message.get<std::string>().c_str());
|
||||
throw CocoaTweet::Exception::InvalidateTokenException(message.get<std::string>().c_str());
|
||||
} else {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -159,8 +159,7 @@ void HttpPost::process(std::weak_ptr<CocoaTweet::Authentication::AuthenticatorBa
|
||||
throw CocoaTweet::Exception::CredentialNotVerifiedException(
|
||||
message.get<std::string>().c_str());
|
||||
} else if (error.get<int>() == 348) {
|
||||
throw CocoaTweet::Exception::InvalidateTokenException(
|
||||
message.get<std::string>().c_str());
|
||||
throw CocoaTweet::Exception::InvalidateTokenException(message.get<std::string>().c_str());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,8 +3,7 @@
|
||||
namespace CocoaTweet::API::Model {
|
||||
|
||||
BearerToken::BearerToken() : token_("") {}
|
||||
BearerToken::BearerToken(const std::string _token)
|
||||
: token_(_token) {}
|
||||
BearerToken::BearerToken(const std::string _token) : token_(_token) {}
|
||||
const std::string& BearerToken::token() const {
|
||||
return token_;
|
||||
}
|
||||
|
||||
@@ -19,14 +19,12 @@ void AccessToken::oauthToken(const CocoaTweet::API::Model::OAuthToken _token) {
|
||||
|
||||
const CocoaTweet::API::Model::OAuthToken AccessToken::process(
|
||||
std::weak_ptr<CocoaTweet::Authentication::AuthenticatorBase> _oauth) {
|
||||
|
||||
auto key = oauth_.lock()->key();
|
||||
key.authType(CocoaTweet::Authentication::Key::AUTH_TYPE::OAUTH10A);
|
||||
key.accessToken(oauthToken_.oauthToken());
|
||||
key.accessTokenSecret(oauthToken_.oauthTokenSecret());
|
||||
auto oauth = std::make_shared<CocoaTweet::Authentication::OAuth1>(key);
|
||||
|
||||
|
||||
CocoaTweet::API::Model::OAuthToken oauthToken;
|
||||
HttpPost::process(oauth, [&oauthToken](const std::string& _rcv) {
|
||||
auto mp = CocoaTweet::Util::parse(_rcv, '&', '=');
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#ifndef COCOATWEET_API_OAUTH1_AUTHENTICATE_H_
|
||||
#define COCOATWEET_API_OAUTH1_AUTHENTICATE_H_
|
||||
|
||||
|
||||
#endif
|
||||
@@ -1,6 +1,4 @@
|
||||
#ifndef COCOATWEET_API_OAUTH1_INVALIDATETOKEN_H_
|
||||
#define COCOATWEET_API_OAUTH1_INVALIDATETOKEN_H_
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
@@ -8,9 +8,9 @@ OAuth::OAuth(std::shared_ptr<CocoaTweet::Authentication::AuthenticatorBase> _oau
|
||||
|
||||
CocoaTweet::API::Model::OAuthToken OAuth::requestToken(
|
||||
const std::string& _oauthCallback) const {
|
||||
// auto key = oauth_.lock()->key();
|
||||
// key.authType(CocoaTweet::Authentication::Key::AUTH_TYPE::OAUTH10A);
|
||||
// auto oauth = std::make_shared<CocoaTweet::Authentication::OAuth1>(key);
|
||||
// auto key = oauth_.lock()->key();
|
||||
// key.authType(CocoaTweet::Authentication::Key::AUTH_TYPE::OAUTH10A);
|
||||
// auto oauth = std::make_shared<CocoaTweet::Authentication::OAuth1>(key);
|
||||
|
||||
CocoaTweet::API::OAuth1::RequestToken requestToken;
|
||||
requestToken.oauthCallback(_oauthCallback);
|
||||
@@ -25,11 +25,11 @@ const std::string OAuth::authorize(const CocoaTweet::API::Model::OAuthToken _oau
|
||||
|
||||
const CocoaTweet::API::Model::OAuthToken OAuth::accessToken(
|
||||
const CocoaTweet::API::Model::OAuthToken _oauthToken, const std::string _verifier) const {
|
||||
// auto key = oauth_.lock()->key();
|
||||
// key.authType(CocoaTweet::Authentication::Key::AUTH_TYPE::OAUTH10A);
|
||||
// key.accessToken(_oauthToken.oauthToken());
|
||||
// key.accessTokenSecret(_oauthToken.oauthTokenSecret());
|
||||
// auto oauth = std::make_shared<CocoaTweet::Authentication::OAuth1>(key);
|
||||
// auto key = oauth_.lock()->key();
|
||||
// key.authType(CocoaTweet::Authentication::Key::AUTH_TYPE::OAUTH10A);
|
||||
// key.accessToken(_oauthToken.oauthToken());
|
||||
// key.accessTokenSecret(_oauthToken.oauthTokenSecret());
|
||||
// auto oauth = std::make_shared<CocoaTweet::Authentication::OAuth1>(key);
|
||||
CocoaTweet::API::OAuth1::AccessToken accessToken;
|
||||
accessToken.oauthVerifier(_verifier);
|
||||
return accessToken.process(oauth_);
|
||||
|
||||
@@ -7,7 +7,7 @@ InvalidateToken::InvalidateToken() {
|
||||
url_ = "https://api.twitter.com/oauth2/invalidate_token";
|
||||
}
|
||||
|
||||
void InvalidateToken::accessToken(const std::string _bearer){
|
||||
void InvalidateToken::accessToken(const std::string _bearer) {
|
||||
// bodyParam_.insert_or_assign("access_token", _bearer);
|
||||
bearer_ = _bearer;
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#include <cocoatweet/api/interface/httpPost.h>
|
||||
#include <cocoatweet/authentication/basic.h>
|
||||
|
||||
namespace CocoaTweet::API::OAuth2{
|
||||
namespace CocoaTweet::API::OAuth2 {
|
||||
class InvalidateToken : public CocoaTweet::API::Interface::HttpPost {
|
||||
public:
|
||||
InvalidateToken();
|
||||
@@ -14,9 +14,8 @@ public:
|
||||
std::weak_ptr<CocoaTweet::Authentication::AuthenticatorBase> _oauth);
|
||||
|
||||
private:
|
||||
std::string bearer_;
|
||||
std::string bearer_;
|
||||
};
|
||||
}
|
||||
|
||||
} // namespace CocoaTweet::API::OAuth2
|
||||
|
||||
#endif
|
||||
@@ -7,16 +7,17 @@ OAuth2::OAuth2(std::shared_ptr<CocoaTweet::Authentication::AuthenticatorBase> _o
|
||||
}
|
||||
|
||||
const std::string OAuth2::token() const {
|
||||
// auto key = oauth_.lock()->key();
|
||||
// auto oauth = std::make_shared<CocoaTweet::Authentication::Basic>(key);
|
||||
// auto key = oauth_.lock()->key();
|
||||
// auto oauth = std::make_shared<CocoaTweet::Authentication::Basic>(key);
|
||||
|
||||
CocoaTweet::API::OAuth2::Token token;
|
||||
return token.process(oauth_);
|
||||
}
|
||||
|
||||
const CocoaTweet::API::Model::BearerToken OAuth2::invalidateToken(const std::string& _bearer) const {
|
||||
// auto key = oauth_.lock()->key();
|
||||
// auto oauth = std::make_shared<CocoaTweet::Authentication::Basic>(key);
|
||||
const CocoaTweet::API::Model::BearerToken OAuth2::invalidateToken(
|
||||
const std::string& _bearer) const {
|
||||
// auto key = oauth_.lock()->key();
|
||||
// auto oauth = std::make_shared<CocoaTweet::Authentication::Basic>(key);
|
||||
|
||||
CocoaTweet::API::OAuth2::InvalidateToken invalidateToken;
|
||||
invalidateToken.accessToken(_bearer);
|
||||
|
||||
@@ -22,13 +22,11 @@ std::string urlEncode(const std::string& _str) {
|
||||
return out.str();
|
||||
}
|
||||
|
||||
std::string urlDecode(const std::string& _str){
|
||||
std::string urlDecode(const std::string& _str) {
|
||||
std::stringstream out;
|
||||
int first = 0;
|
||||
int last = _str.find_first_of('%');
|
||||
|
||||
|
||||
|
||||
while (first < _str.size()) {
|
||||
if (last == std::string::npos) {
|
||||
out << _str.substr(first);
|
||||
@@ -36,7 +34,7 @@ std::string urlDecode(const std::string& _str){
|
||||
}
|
||||
|
||||
auto s = _str.substr(first, last - first);
|
||||
auto encoded = _str.substr(last+1, 2); // %を飛ばし読みする
|
||||
auto encoded = _str.substr(last + 1, 2); // %を飛ばし読みする
|
||||
|
||||
std::cout << encoded << std::endl;
|
||||
auto c = static_cast<char>(static_cast<int>(strtol(encoded.c_str(), nullptr, 16)));
|
||||
|
||||
@@ -49,8 +49,6 @@ auto main() -> int {
|
||||
user = api.user().show("milkcocoa9692");
|
||||
std::cout << user.id() << std::endl;
|
||||
|
||||
|
||||
|
||||
// api.directMessage().messageCreate(
|
||||
// user.id(),
|
||||
// "これはクソみたいなスパムDMです。\nCocoaTwitterLibraryで、user/"
|
||||
|
||||
Reference in New Issue
Block a user