Skip to content

[App] Twitter

HouzuoGuo edited this page Oct 9, 2022 · 3 revisions

Introduction

Post Tweets and read tweets from home time-line.

Preparation

Create your very own Twitter application:

  1. Visit Twitter Developers.
  2. Navigate to My apps.
  3. Proceed to create a new application, fill in the name, description, and website. Leave callback URL empty.

And then, obtain an API access token:

  1. Visit your newly created app, navigate to "Key and Access Tokens" tab.
  2. Note down your "Consumer Key (API Key)" and "Consumer Secret (API Secret)".
  3. Click "Create my access token".
  4. Note down your "Access Token" and "Access Token Secret".

The keys and secrets do not expire. They will be used in laitos configuration.

Configuration

Under JSON object Features, construct a JSON object called Twitter that has the following mandatory properties:

Property Type Meaning
AccessToken string API access token.
AccessTokenSecret string API access token secret.
ConsumerKey string Consumer (application) API key.
ConsumerSecret string Consumer (application) API secret.

Here is an example:

{
    ...

    "Features": {
        ...

        "Twitter": {
            "AccessToken": "12345678-erngbfuninxkjnxvvvvveruihuiuiersuiiidf",
            "AccessTokenSecret": "iowa4jiojiobniofgnncvbmknbnyrtubyt",
            "ConsumerKey": "fxoieprkpokpowwwwmcgbmkk",
            "ConsumerSecret": "xvm,mbrypziweijzwemimfdrtgjkbmfgmkkm"
        },

        ...
    },

    ...
}

Usage

Use any capable laitos daemon to invoke the app:

  • Post a tweet: .tp tweet content, a short moment later the command response will say a number that is length of tweet.
  • Read latest tweets from home time-line: .tg skip count, where skip is the number of latest tweets to discard, and count is the number of tweets to read after discarding.

Be aware: Twitter will only allow retrieving up to 200 latest tweets, that means skip + count may not exceed 200.

Clone this wiki locally