statuses_usertimelineを叩くやつの実装(#66)
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
#include "cocoatweet/api/status/userTimeline.h"
|
||||
#include <cocoatweet/util/util.h>
|
||||
#include "nlohmann/json.hpp"
|
||||
#include <iostream>
|
||||
|
||||
namespace CocoaTweet::API::Statuses {
|
||||
UserTimeline::UserTimeline() {
|
||||
contentType_ = "application/x-www-form-urlencoded";
|
||||
url_ = "https://api.twitter.com/1.1/statuses/user_timeline.json";
|
||||
}
|
||||
|
||||
void UserTimeline::screenName(const std::string& _screenName) {
|
||||
bodyParam_.insert_or_assign("screen_name", _screenName);
|
||||
}
|
||||
|
||||
std::vector<CocoaTweet::API::Model::Tweet> UserTimeline::process(
|
||||
std::weak_ptr<CocoaTweet::OAuth::OAuth1> _oauth) {
|
||||
std::vector<CocoaTweet::API::Model::Tweet> tweet;
|
||||
HttpGet::process(_oauth, [&tweet](const unsigned int _responseCode, const std::string& _rsv) {
|
||||
auto json = nlohmann::json::parse(_rsv);
|
||||
for (auto j : json) {
|
||||
tweet.push_back(CocoaTweet::API::Model::Tweet::parse(_responseCode, j.dump()));
|
||||
std::cout << j.dump() << std::endl;
|
||||
}
|
||||
});
|
||||
return tweet;
|
||||
}
|
||||
|
||||
} // namespace CocoaTweet::API::Statuses
|
||||
Reference in New Issue
Block a user