Script integration with Twitter. The updateStatus method is a convenience method for posting a tweet, but the entire Twitter API can be used with the request method, which handles OAuth authentication and authorization.

Example

// create twitter object
let twitter = Twitter.create();
// post tweet
let success = twitter.updateStatus("My tweet content!");

if success {
console.log(twitter.lastResponse);
}
else {
console.log(twitter.lastError);
context.fail();
}

Hierarchy

  • Twitter

Constructors

  • Create new instance.

    Parameters

    • Optional identifier: string

    Returns Twitter

Methods

  • Execute a request against the Twitter API. For successful requests, the HTTPResponse object will contain an object or array or objects decoded from the JSON returned by Twitter as appropriate to the request made. Refer to Twitter’s API documentation for details about the expected parameters and responses. Drafts will handle wrapping the request in the appropriate OAuth authentication flow.

    Parameters

    • settings: {
          data?: {
              [x: string]: string;
          };
          headers?: {
              [x: string]: string;
          };
          method: string;
          parameters?: {
              [x: string]: string;
          };
          url: string;
      }

      an object with the following properties:

      • url [string, required]: The full URL to the endpoint in the Twitter API.
      • method [string, required]: The HTTP method, like "GET", "POST", etc.
      • headers [object, optional]: An object contain key-values to be added as custom headers in the request. There is no need to provide authorization headers, Drafts will add those.
      • parameters [object, optional]: An object containing key-values to be added to the request as URL parameters.
      • data [object, optional]: An object containing data to be encoded into the HTTP body of the request.
      • Optional data?: {
            [x: string]: string;
        }
        • [x: string]: string
      • Optional headers?: {
            [x: string]: string;
        }
        • [x: string]: string
      • method: string
      • Optional parameters?: {
            [x: string]: string;
        }
        • [x: string]: string
      • url: string

    Returns HTTPResponse

  • Post a status update (tweet) to Twitter. Returns true if successful, false if not. After success the lastResponse object can be used to inspect response and get details such as the ID of the tweet created. Refer to Twitter API POST /status/update documentation for response details.

    Parameters

    • content: string

    Returns boolean

  • Creates a new Twitter object. Identifier is a optional string value used to identify a Twitter account. Typically this can be omitted if you only work with one Twitter account in Drafts. Each unique identifier used for Twitter accounts will share credentials - across both action steps and scripts.

    Parameters

    • identifier: string

    Returns Twitter

Generated using TypeDoc