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.
an optional identifier in case you wish to use multiple Pastebin accounts. The default is simply Pastebin
.
Developer key for the Pastebin API.
Session token for the Pastebin API
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
.
the content to push to Pastebin a new paste.
an optional title for the new paste. The default is to have no title.
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.
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.
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.
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.
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.
TadPastebin (Library)
This is a class that is used for interacting with Pastebin (https://pastebin.com).