Skip to content

Instantly share code, notes, and snippets.

@extratone
Created April 29, 2022 10:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save extratone/5b19bbe77567c5ba17f60e7bd6bfa044 to your computer and use it in GitHub Desktop.
Save extratone/5b19bbe77567c5ba17f60e7bd6bfa044 to your computer and use it in GitHub Desktop.
Full install URL for my "Post to Writeas" Drafts action.
drafts://action?data=%7B%22uuid%22:%22A39DEA32-ADB8-49D0-9D51-8D02BDA5570F%22,%22steps%22:%5B%7B%22platforms%22:3,%22data%22:%7B%22script%22:%22%5C/%5C/%20setup%20and%20request%20credentials%5Cnlet%20credential%20%3D%20Credential.create(%5C%22Write.as%5C%22,%20%5C%22Enter%20your%20target%20Writeas%20blog%20slug%20(collection)%20and%20Writeas%5C/Snapas%20API%20auth%20token.%5C%22);%5Cr%5Cn%5Cr%5Cncredential.addTextField(%5C%22collection%5C%22,%20%5C%22Collection%5C%22);%5Cr%5Cncredential.addPasswordField(%5C%22token%5C%22,%20%5C%22Access%20Token%5C%22);%5Cr%5Cncredential.authorize();%5Cn%5Cnconst%20token%20%3D%20credential.getValue(%5C%22token%5C%22);%5Cn%5Cn%5C/%5C/%20make%20post%5Cnlet%20endpoint%20%3D%20%60https:%5C/%5C/write.as%5C/api%5C/posts%60;%5Cn%5Cn%5C/%5C/%20configure%20post%20details%5Cn%5C/%5C/%20for%20more%20information,%20see:%5Cn%5C/%5C/%20https:%5C/%5C/developers.write.as%5C/docs%5C/api%5Cnlet%20data%20%3D%20%7B%5Cn%5Ct%5C%22body%5C%22:%20draft.content,%5Cn%7D;%5Cn%5Cn%5C/%5C/%20create%20and%20post%20HTTP%20request%5Cnvar%20http%20%3D%20HTTP.create();%5Cn%5Cnvar%20response%20%3D%20http.request(%7B%5Cn%5Ct%5C%22url%5C%22:%20endpoint,%5Cn%5Ct%5C%22method%5C%22:%20%5C%22POST%5C%22,%5Cn%5Ct%5C%22data%5C%22:%20data,%5Cn%5Ct%5C%22headers%5C%22:%20%7B%5Cn%5Ct%5Ct%5C%22Authorization%5C%22%20:%20token,%5Cn%5Ct%7D%5Cn%7D);%5Cn%5Cn%5C/%5C/%20log%20result%20post%20URL%20and%20copy%20to%20clipboard%5Cnif%20(response.statusCode%20%3D%3D%20201)%20%7B%5Cn%5Ctlet%20d%20%3D%20JSON.parse(response.responseText);%5Cn%5Ctconsole.log(%5C%22Posted%20to%20Writeas.%20URL:%20%5C%22%20+%20d.data.url);%5Cn%5Ctapp.setClipboard(d.data.url);%5Cn%5Ctdraft.setTemplateTag(%5C%22walink%5C%22,%20d.data.url);%5Cn%7D%5Cn%5Cnelse%20%7B%5Cn%5Ctconsole.log(%5C%22Write.as%20Error:%20%5C%22%20+%20response.error);%5Cn%5Ctcontext.fail();%5Cn%7D%22,%22allowAsync%22:%22false%22%7D,%22type%22:%22script%22,%22isEnabled%22:true,%22uuid%22:%220C5E6E2C-599E-49A8-8409-0E1850CD74DE%22%7D,%7B%22platforms%22:3,%22data%22:%7B%22template%22:%22%5Cn-%20%5B%5B%5Bdisplay_title%5D%5D%5D(%5B%5Bwalink%5D%5D)%22%7D,%22type%22:%22insertText%22,%22isEnabled%22:true,%22uuid%22:%22DA788237-8B3E-4A51-B2DD-B1A94085080A%22%7D%5D,%22backingPlatforms%22:3,%22shortName%22:%22%22,%22shouldConfirm%22:false,%22disposition%22:0,%22keyCommand%22:%7B%22optionKey%22:false,%22input%22:%22%22,%22controlKey%22:false,%22commandKey%22:false,%22type%22:%22action%22,%22discoverabilityTitle%22:%22Post%20to%20Writeas%22,%22shiftKey%22:false%7D,%22logLevel%22:2,%22groupDisposition%22:0,%22notificationType%22:2,%22tintColor%22:%22green%22,%22actionDescription%22:%22Post%20to%20Write.as%20via%20the%20Write.as%20API.%22,%22keyUseIcon%22:false,%22icon%22:%22sim-card%22,%22visibility%22:480,%22backingIsSeparator%22:false,%22groupUUID%22:%22DB5C51F1-9C68-4DE6-A310-33180D6E784D%22,%22assignTags%22:%5B%5D,%22name%22:%22Post%20to%20Writeas%22%7D
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment