Action

葫芦笔记

Posted by 麦麦, Last update over 3 years ago - Unlisted

发送笔记到葫芦笔记中的每日笔记。

Steps

  • script

    var credential = Credential.create("Api for Hulunote", "Hulunote");
    credential.addPasswordField("huluapi", "Api for Hulunote");
    credential.authorize();
    
    var tags = draft.tags ? draft.tags : [];
    var tagLine = tags.map(t => '#' + t).join(' ');
    var title = draft.processTemplate('[[title]]');
    var body = draft.processTemplate('[[body]]');
    
    var content = title + " " + tagLine + "\n" + body;
    
    var http = HTTP.create();
    var response = http.request({
      "url": credential.getValue("huluapi"),
      "encoding": "json",
      "method": "POST",
      "data": {
        "content": content
      }
    });
    
    if (response.error) {
      console.log(response.error);
      context.fail(response.error.message);
    } else {
      var rText = JSON.parse(response.responseText);
      if (rText.code != "0") {
        app.displayErrorMessage(rText.message);
      }
    }
    
    

Options

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