Options
All
  • Public
  • Public/Protected
  • All
Menu

Class TadPastebin

TadPastebin (Library)

This is a class that is used for interacting with Pastebin (https://pastebin.com).

Hierarchy

  • TadPastebin

Index

Constructors

Properties

Methods

Constructors

constructor

  • Create new instance of the TadPastebin class. The construction triggers the specification/retrieval form the Drafts credentials store, of the user name, password, and developer key (for the API). It then uses those to generate a session token for interacting with Pastebin.

    When you are logged into Pastebin.com, the developer key is shown in the "Your Unique Developer API Key" section on the API documentation page.

    Parameters

    • p_strID: string

      an optional identifier in case you wish to use multiple Pastebin accounts. The default is simply Pastebin.

    Returns TadPastebin

Properties

apikey

apikey: string

Developer key for the Pastebin API.

token

token: string

Session token for the Pastebin API

Methods

TA_postToPastebin

  • TA_postToPastebin(p_strContent: string, p_strTitle: string, p_bCopyResult?: Boolean, p_intPrivacy?: number, p_strSyntax?: string, p_strExpiry?: string, p_strFolderID?: string): string
  • Post content to Pastebin as a new paste. This function returns the URL of the newly created paste when successful. If unsuccessful an error message is displayed and the function will return undefined.

    Parameters

    • p_strContent: string

      the content to push to Pastebin a new paste.

    • p_strTitle: string

      an optional title for the new paste. The default is to have no title.

    • Optional p_bCopyResult: Boolean

      when set to true, the default, a link to the newly created paste will be copied to the clipboard. When set to false, or if the creation fails, no change to the clipboard will take place.

    • Optional p_intPrivacy: number

      this can be set to 0,1 or 2. The default is 0 and will result in a paste that is available publicly. When set to 1, it will be available publicly, but not listed publicly. When set to 2 the paste will be private and not available publicly.

    • Optional p_strSyntax: string

      by default, a new paste will not be formatted for any particular syntax. However, over 200 syntaxes are supported. Pass in the relevant syntax name as a string for this parameter to set the syntax - available syntaxes are listed against the api_paste_format API option listed on the API documentation page.

    • Optional p_strExpiry: string

      by default pastes are not set to expire, but the Pastebin supports shorthand text strings that it can parse to specify an expiry. Details of how to construct these strings can be found on the API documentation page under the details for the api_paste_expire_date API option.

    • Optional p_strFolderID: string

      by default pastes are not saved to a folder, but you can choose to save them to a particular folder. Enter the ID string for your folder for this paramater. The ID is the last part of the URL for viewing your folder.

      // Example
      let pb = new TadPastebin();
      pb.TA_postToPastebin("//Display hello world\nlalert('Hello World');", "JS First Example", true, 0, "javascript", "1M", "m0vKrV88");
      //Posts a publicly available JavaScript example, available for one month and saved to a folder, the URL being copied to the clipboard.

    Returns string