doc
This commit is contained in:
@@ -104,6 +104,39 @@ then you can load api key from json file.
|
|||||||
CocoaTweet::Authentication::Key key = CocoaTweet::Authentication::Key::fromJsonFile("api_key.json");
|
CocoaTweet::Authentication::Key key = CocoaTweet::Authentication::Key::fromJsonFile("api_key.json");
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### 3. Authenticate with API call
|
||||||
|
※ consumer key, consumer secret are needed. in this case, get access token with api call.
|
||||||
|
```
|
||||||
|
CocoaTweet::API::API api(key);
|
||||||
|
|
||||||
|
auto oAuthToken = api.oauth1().requestToken("oob");
|
||||||
|
const auto signInUrl = api.oauth1().authorize(oAuthToken);
|
||||||
|
std::cout << "signin : " << signInUrl << std::endl;
|
||||||
|
std::string pin = "";
|
||||||
|
std::cout << "pincode : ";
|
||||||
|
std::cin >> pin;
|
||||||
|
|
||||||
|
const auto validOAuthToken = api.oauth1().accessToken(oAuthToken, pin);
|
||||||
|
key.accessToken(validOAuthToken.oauthToken());
|
||||||
|
key.accessTokenSecret(validOAuthToken.oauthTokenSecret());
|
||||||
|
api.swapKey(key);
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
### 4. Get BearerToken with AIP call
|
||||||
|
if you want to call Twitter API using Bearer Token; OAuth2, you can do.
|
||||||
|
```
|
||||||
|
CocoaTweet::API::API api(key);
|
||||||
|
auto bearerToken = api.oauth2().token();
|
||||||
|
key.bearerToken(bearerToken);
|
||||||
|
key.authType(CocoaTweet::Authentication::Key::AUTH_TYPE::OAUTH2);
|
||||||
|
api.swapKey(key);
|
||||||
|
```
|
||||||
|
|
||||||
|
After call it, always use Bearer Token to access API which kinds of GET method.
|
||||||
|
no affect to POST method.
|
||||||
|
then, if you use this, and ONLY use kind of GET API, you DO NOT need acess token.
|
||||||
|
|
||||||
## Generate API object
|
## Generate API object
|
||||||
generating API object with Key.
|
generating API object with Key.
|
||||||
this object is API entry point.
|
this object is API entry point.
|
||||||
@@ -115,15 +148,6 @@ CocoaTweet::API::API api(key);
|
|||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### NOTE
|
|
||||||
if you want to call Twitter API using Bearer Token; OAuth2, you can do.
|
|
||||||
```
|
|
||||||
api.generateBearerToken();
|
|
||||||
```
|
|
||||||
After call it, always use Bearer Token to access API which kinds of GET method.
|
|
||||||
no affect to POST method.
|
|
||||||
then, if you use this, and ONLY use kind of GET API, you DO NOT need acess token.
|
|
||||||
|
|
||||||
|
|
||||||
## Use API
|
## Use API
|
||||||
```
|
```
|
||||||
|
|||||||
Reference in New Issue
Block a user