Action

omg.lol weblog

Posted by maique, Last update over 1 year ago

This action creates a new post on omg.lol’s weblog service, weblog.lol.

If you’d like a title on your post, make sure the first line is “# title of post”. Otherwise the title will be whatever comes first.

You’ll need an omg.lol account, and the API key for that account. You’ll be asked for both during first run.

Thanks to:

podiboq https://actions.getdrafts.com/a/2DT

Colin Devroe https://mastodon.social/@cdevroe
Adam https://social.lol/@adam

Steps

  • script

    // Storing the omg.lol credentials in Draft's Credential instead of the action code directly
    // Thank you podiboq: https://actions.getdrafts.com/a/2DT
    
    var credential = Credential.create("omg.lol weblog", "Store your omg.lol API key username privately");
    credential.addTextField("omg_username", "Your username");
    credential.addPasswordField("omg_api_key", "API Key");
    credential.authorize();
    
    // Get the values and store them: 
    let omg_api_key = credential.getValue("omg_api_key")
    let omg_username = credential.getValue("omg_username")
    
    var d = new Date("2015-12-01 21:15");
    
    var content = draft.processTemplate("[[draft]]");
    
    var random = Math.random().toString().substr(2, 8);
    
      var http = HTTP.create();
      var response = http.request({
    	"url": "https://api.omg.lol/address/" + omg_username + "/weblog/entry/" + random + "/",
    	"method": "POST",
    	"data": { "content": content},
    	"headers": {
    	  "Authorization": "Bearer " + omg_api_key
    	}
      });

Options

  • After Success Nothing , Tags: omg, weblog
    Notification Info
    Log Level Info
Items available in the Drafts Directory are uploaded by community members. Use appropriate caution reviewing downloaded items before use.