READMEとかmain.cのサンプルとか変更

This commit is contained in:
keita
2021-02-18 16:28:25 +09:00
parent 5e2a5d1712
commit 055ee555b1
2 changed files with 24 additions and 16 deletions
+7 -3
View File
@@ -6,9 +6,10 @@ This is a library for using Twitter API from C++
- libssl - libssl
# Features # Features
you can use these endpoint
- statuses/update - statuses/update
- favorites/create
Now, only post a tweet.
# How # How
## API Key Registration ## API Key Registration
@@ -56,8 +57,11 @@ CocoaTweet::API::API api(key);
``` ```
## Post Tweet ## Use API
post tweet
``` ```
// Post a tweet
api.status().Update("Hello, World!!\nTweet from Cocoa Twitter Library"); api.status().Update("Hello, World!!\nTweet from Cocoa Twitter Library");
// Fav. to tweet
api.favorite().Create("tweet id");
``` ```
+17 -13
View File
@@ -2,20 +2,24 @@
#include "cocoatweet/api/api.h" #include "cocoatweet/api/api.h"
auto main() -> int { auto main() -> int {
// キーオブジェクトを作成 // Generate Key object
// auto consumerKey = "your consumer key"; // auto consumerKey = "your consumer key";
// auto consumerSecret = "your consumer secret"; // auto consumerSecret = "your consumer secret";
// auto accessToken = "your access token"; // auto accessToken = "your access token";
// auto accessTokenSecret = "your access token secret"; // auto accessTokenSecret = "your access token secret";
// CocoaTweet::OAuth::Key key = CocoaTweet::OAuth::Key(consumerKey, consumerSecret, // CocoaTweet::OAuth::Key key = CocoaTweet::OAuth::Key(consumerKey,
// accessToken, accessTokenSecret); // consumerSecret,
// accessToken,
// accessTokenSecret);
// jsonファイルから各種キーを読み込むことも可能
CocoaTweet::OAuth::Key key = CocoaTweet::OAuth::Key::fromJsonFile("apikey.json");
// 作成したキーオブジェクトを用いてAPIを立ち上げる. // also can generate Key object from JSON file
// 内部的にはキーオブジェクトを使用してOAuth認証機を立ち上げている. // CocoaTweet::OAuth::Key key = CocoaTweet::OAuth::Key::fromJsonFile("api_key.json");
CocoaTweet::API::API api(key);
api.status().Update("Hello Twitter World from Cocoa Twitter Library"); // Generate API Entry object using Key object
// CocoaTweet::API::API api(key);
// Now, you can use a twitter api
// api.status().Update("Hello Twitter World from Cocoa Twitter Library");
// api.favorite().Create("tweet id you want to fav.");
} }