Action
Prompt Tweet
Prompt to capture a tweet, then give the option to tweet it immediately or save it for later. Cancel to remove forever. Ideally used with the Drafts grid widget in iOS and iPadOS 14.
Created by @nahumck.
Steps
-
script
/*--- Prompt ---*/ var p = Prompt.create(); p.title = "Tweet Composer" p.message = "Tweet limited to 250 characters"; p.addTextView("tweetText","Tweet","",{autocapitalization:"sentences",autocorrect:true,height:"150",wantsFocus:true}) p.addButton("Tweet"); p.addButton("Save"); var con = p.show();
-
script
/*--- Actions ---*/ if (con) { let text = p.fieldValues["tweetText"]; if (p.buttonPressed == "Tweet") { // create twitter object var twitter = Twitter.create(); // post tweet var success = twitter.updateStatus(text); if (success) { console.log(twitter.lastResponse); } else { console.log(twitter.lastError); context.fail(); } } if (p.buttonPressed == "Save") { let d = Draft.create(); d.content = text; d.addTag("tweet"); d.update(); } } else { context.cancel() }
Options
-
After Success Default Notification Info Log Level Error
Items available in the Drafts Directory are uploaded by community members. Use appropriate caution reviewing downloaded items before use.