ユーザオブジェクト
This commit is contained in:
@@ -7,6 +7,32 @@ CocoaTweet::API::Model::User User::parse(const std::string& _json) {
|
|||||||
User user;
|
User user;
|
||||||
|
|
||||||
user.id(j["id_str"]);
|
user.id(j["id_str"]);
|
||||||
|
user.name(j["name"]);
|
||||||
|
user.screenName(j["screen_name"]);
|
||||||
|
if (j["location"].is_null() == false) {
|
||||||
|
user.location(j["location"]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (j["url"].is_null() == false) {
|
||||||
|
user.location(j["url"]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (j["description"].is_null() == false) {
|
||||||
|
user.location(j["description"]);
|
||||||
|
}
|
||||||
|
|
||||||
|
user.protectedUser(j["protected"]);
|
||||||
|
user.follower(j["followers_count"]);
|
||||||
|
user.follow(j["friends_count"]);
|
||||||
|
user.listed(j["listed_count"]);
|
||||||
|
user.favorite(j["favourites_count"]);
|
||||||
|
if (j["profile_banner_url"].is_null() == false) {
|
||||||
|
user.bannerUrl(j["profile_banner_url"]);
|
||||||
|
}
|
||||||
|
if (j["profile_image_url_https"].is_null() == false) {
|
||||||
|
user.iconUrl(j["profile_image_url_https"]);
|
||||||
|
}
|
||||||
|
|
||||||
return user;
|
return user;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -25,9 +51,80 @@ void User::screenName(const std::string& _screen) {
|
|||||||
void User::location(const std::string& _location) {
|
void User::location(const std::string& _location) {
|
||||||
location_ = _location;
|
location_ = _location;
|
||||||
}
|
}
|
||||||
|
void User::url(const std::string& _url) {
|
||||||
|
url_ = _url;
|
||||||
|
}
|
||||||
|
void User::description(const std::string& _description) {
|
||||||
|
description_ = _description;
|
||||||
|
}
|
||||||
|
|
||||||
|
void User::protectedUser(const bool _protected) {
|
||||||
|
protectedUser_ = _protected;
|
||||||
|
}
|
||||||
|
void User::follower(const long _follower) {
|
||||||
|
follower_ = _follower;
|
||||||
|
}
|
||||||
|
void User::follow(const long _follow) {
|
||||||
|
follow_ = _follow;
|
||||||
|
}
|
||||||
|
void User::listed(const long _listed) {
|
||||||
|
listed_ = _listed;
|
||||||
|
}
|
||||||
|
void User::favorite(const long _favorite) {
|
||||||
|
favorite_ = _favorite;
|
||||||
|
}
|
||||||
|
void User::createdAt(const std::string& _created) {
|
||||||
|
createdAt_ = _created;
|
||||||
|
}
|
||||||
|
void User::bannerUrl(const std::string& _banner) {
|
||||||
|
bannerUrl_ = _banner;
|
||||||
|
}
|
||||||
|
void User::iconUrl(const std::string& _icon) {
|
||||||
|
iconUrl_ = _icon;
|
||||||
|
}
|
||||||
|
|
||||||
const std::string& User::id() const {
|
const std::string& User::id() const {
|
||||||
return id_;
|
return id_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const std::string& User::name() const {
|
||||||
|
return name_;
|
||||||
|
}
|
||||||
|
const std::string& User::screenName() const {
|
||||||
|
return screenName_;
|
||||||
|
}
|
||||||
|
const std::string& User::location() const {
|
||||||
|
return location_;
|
||||||
|
}
|
||||||
|
const std::string& User::url() const {
|
||||||
|
return url_;
|
||||||
|
}
|
||||||
|
const std::string& User::description() const {
|
||||||
|
return description_;
|
||||||
|
}
|
||||||
|
bool User::protectedUser() const {
|
||||||
|
return protectedUser_;
|
||||||
|
}
|
||||||
|
long User::follower() const {
|
||||||
|
return follower_;
|
||||||
|
}
|
||||||
|
long User::follow() const {
|
||||||
|
return follow_;
|
||||||
|
}
|
||||||
|
long User::listed() const {
|
||||||
|
return listed_;
|
||||||
|
}
|
||||||
|
long User::favorite() const {
|
||||||
|
return favorite_;
|
||||||
|
}
|
||||||
|
const std::string& User::created() const {
|
||||||
|
return createdAt_;
|
||||||
|
}
|
||||||
|
const std::string& User::bannerUrl() const {
|
||||||
|
return bannerUrl_;
|
||||||
|
}
|
||||||
|
const std::string& User::icon() const {
|
||||||
|
return iconUrl_;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace CocoaTweet::API::Model
|
} // namespace CocoaTweet::API::Model
|
||||||
|
|||||||
@@ -34,7 +34,6 @@ public:
|
|||||||
void follow(const long _follow);
|
void follow(const long _follow);
|
||||||
void listed(const long _listed);
|
void listed(const long _listed);
|
||||||
void favorite(const long _favorite);
|
void favorite(const long _favorite);
|
||||||
void tweet(const long _tweet);
|
|
||||||
void createdAt(const std::string& _created);
|
void createdAt(const std::string& _created);
|
||||||
void bannerUrl(const std::string& _banner);
|
void bannerUrl(const std::string& _banner);
|
||||||
void iconUrl(const std::string& _icon);
|
void iconUrl(const std::string& _icon);
|
||||||
@@ -50,9 +49,8 @@ public:
|
|||||||
long follow() const;
|
long follow() const;
|
||||||
long listed() const;
|
long listed() const;
|
||||||
long favorite() const;
|
long favorite() const;
|
||||||
long tweet() const;
|
|
||||||
const std::string& created() const;
|
const std::string& created() const;
|
||||||
const std::string& banner() const;
|
const std::string& bannerUrl() const;
|
||||||
const std::string& icon() const;
|
const std::string& icon() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -67,7 +65,6 @@ private:
|
|||||||
long follow_;
|
long follow_;
|
||||||
long listed_;
|
long listed_;
|
||||||
long favorite_;
|
long favorite_;
|
||||||
long tweet_;
|
|
||||||
std::string createdAt_;
|
std::string createdAt_;
|
||||||
std::string bannerUrl_;
|
std::string bannerUrl_;
|
||||||
std::string iconUrl_;
|
std::string iconUrl_;
|
||||||
|
|||||||
+7
-8
@@ -29,20 +29,19 @@ auto main() -> int {
|
|||||||
// accessTokenSecret);
|
// accessTokenSecret);
|
||||||
|
|
||||||
// also can generate Key object from JSON file
|
// also can generate Key object from JSON file
|
||||||
CocoaTweet::OAuth::Key key = CocoaTweet::OAuth::Key::fromJsonFile("api_key.json");
|
// CocoaTweet::OAuth::Key key = CocoaTweet::OAuth::Key::fromJsonFile("api_key.json");
|
||||||
// auto oauth = CocoaTweet::OAuth::OAuth1(key);
|
|
||||||
// oauth.GenerateBearerToken();
|
|
||||||
|
|
||||||
// std::cout << "sdfgwregfresgfresdwefgweragregreagretgreawgrt#$QTWREATGREWTGF$ERTF";
|
|
||||||
// Generate API Entry object using Key object
|
// Generate API Entry object using Key object
|
||||||
CocoaTweet::API::API api(key);
|
// CocoaTweet::API::API api(key);
|
||||||
// std::cout << api.generateBearerToken() << std::endl;
|
|
||||||
|
// 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();
|
||||||
|
|
||||||
// Now, you can use a twitter api
|
// Now, you can use a twitter api
|
||||||
// auto status = api.status().update("Hello Twitter World via Cocoa Twitter Library");
|
// auto status = api.status().update("Hello Twitter World via Cocoa Twitter Library");
|
||||||
// api.favorite().create(status.id());
|
// api.favorite().create(status.id());
|
||||||
// api.favorite().destroy(status.id());
|
// api.favorite().destroy(status.id());
|
||||||
// api.status().destroy(status.id());
|
// api.status().destroy(status.id());
|
||||||
auto timeline = api.status().userTimeline("milkcocoa0902");
|
// auto timeline = api.status().userTimeline("milkcocoa0902");
|
||||||
std::cout << timeline[0].user().id();
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user