This commit is contained in:
keita
2021-10-07 21:50:46 +09:00
parent d3d0dc96fd
commit e7c0df8e99
5 changed files with 31 additions and 28 deletions
+2 -1
View File
@@ -103,8 +103,9 @@ void HttpGet::process(std::weak_ptr<CocoaTweet::OAuth::OAuth1> _oauth,
throw std::runtime_error(std::string("INTERNAL ERROR : curl(") + std::to_string(res) + ")");
exit(1);
}
#ifndef NDEBUG
std::cout << rcv << std::endl;
#endif
if ((responseCode / 100) == 4) {
auto j = nlohmann::json::parse(rcv);
auto error = j["errors"][0]["code"];
+3
View File
@@ -114,6 +114,9 @@ void HttpPost::process(std::weak_ptr<CocoaTweet::OAuth::OAuth1> _oauth,
exit(1);
}
#ifndef NDEBUG
std::cout << rcv << std::endl;
#endif
if ((responseCode / 100) == 4) {
auto j = nlohmann::json::parse(rcv);
auto error = j["errors"][0]["code"];
+12 -23
View File
@@ -1,21 +1,6 @@
#include "cocoatweet/oauth/key.h"
#include "cocoatweet/api/api.h"
#include <cocoatweet/api/directMessage/new.h>
#include <cocoatweet/api/api.h>
#include <iostream>
#include <fstream>
#include <algorithm>
#include <unistd.h>
#include <nlohmann/json.hpp>
#include <cocoatweet/exception/exception.h>
#include <cocoatweet/exception/rateLimitException.h>
bool starts_with(const std::string& s, const std::string& prefix) {
auto size = prefix.size();
if (s.size() < size) return false;
return std::equal(std::begin(prefix), std::end(prefix), std::begin(s));
}
auto main() -> int {
// Generate Key object
@@ -36,12 +21,16 @@ auto main() -> int {
// if you want to access api using Bearer Token, call this for get BearerToken;
// NOTE: call this, always authenticate with Bearer Token, which is Read Only Token
// api.generateBearerToken();
// try {
// api.generateBearerToken();
// Now, you can use a twitter api
// auto status = api.status().update("Hello Twitter World via Cocoa Twitter Library");
// api.favorite().create(status.id());
// api.favorite().destroy(status.id());
// api.status().destroy(status.id());
// auto timeline = api.status().userTimeline("milkcocoa0902");
// Now, you can use a twitter api
// auto status = api.status().update("Hello Twitter World via Cocoa Twitter Library");
// api.favorite().create(status.id());
// api.favorite().destroy(status.id());
// api.status().destroy(status.id());
// auto timeline = api.status().userTimeline("milkcocoa0902");
// } catch (CocoaTweet::Exception::Exception e) {
// std::cout << e.what() << std::endl;
// }
}