Action

Tweet and Toot

Posted by @mattbirchler, Last update about 6 years ago

This shares draft content to Twitter and Mastodon. Setup requires you to go to https://mastodon.social/settings/applications to set up an app in your Mastodon settings. Paste that key into the script and it should work very nicely.

This only works with mastodon.social right now, but clever users might be able to adjust this to work with the version of Mastodon they’d like.

Steps

  • script

    // Go to https://mastodon.social/settings/applications
    // to generate an app license for your account.
    // Currently only works with Mastodon.social
    var credential = "123456789012345678901234567890123456789012345";
    
    // Setup Mastodon.social API and content 
    var endpoint = "https://mastodon.social/api/v1/statuses";
    var content = draft.content;
    
    var d = new Date();
    var rawTime = d.getFullYear();
    var date = d.getFullYear() + "-" + d.getMonth() + "-" + d.getDate();
    
    var id_key = "Drafts" + rawTime + "T" + date + "App";
    
    
    // create and post HTTP request
    var http = HTTP.create();
    
    var response = http.request({
      "url": endpoint,
      "method": "POST",
      "data": {
      		"status" : content
      },
      "headers": {
        "Authorization" : "Bearer " + credential,
        "idempotency_key" : id_key
      }
    });
  • twitter

    template
    [[draft]]

Options

  • After Success Default
    Notification Info
    Log Level Info
Items available in the Drafts Directory are uploaded by community members. Use appropriate caution reviewing downloaded items before use.