Before I wrote my previous post, I put out a call on Twitter for an iOS app that cleans short links and that also supports x-callback-url. After all the work of adapting a Pythonista script to resolve a short Dropbox link, I finally received a response from @malanowski: Clean Links. Although I cannot find any x-callback-url documentation on the web, there is documentation in the app itself.
I’ve now written a Launch Center Pro action that does the exact same thing as described in my previous post but without the hassle of creating a script in Pythonista. All you have to do is tap on this link while on your iPhone and install the action in Launch Center Pro.
Take a photo, tap on the LCP action, and your shared Dropbox image is available for publication in Markdown format in TextTool. From there you can tap on Open In...
to send to your favorite text editor.
The Geeky Details
This action uses three x=success
parameters, each of which is URL-encoded. The final TextTool transform is tripe-URL-encoded.
launchpro-dropbox://addlastphoto?path=&name=&quality=&getlink=1&x-success=clean-links%3A%2F%2Fx-callback-url%2Fclean%3Furl%3D%5Bclipboard%5D%26retParam%3Dtext%26x-success%3Dtexttool%253A%252F%252Fx-callback-url%252Ftransform%253Fmethod%253Dreplace%2526find%253Dwww%2526replace%253Ddl%2526x-success%253Dtexttool%25253A%25252F%25252Fx-callback-url%25252Ftransform%25253Ftext%25253D%25255B%25255Boutput%25255D%25255D%252526method%25253Daffix%252526prefix%25253D!%2525255B%2525255D%25252528%252526suffix%25253D%25252529
First, LCP adds the last-taken photo to Dropbox — by default to /Apps/Launch Center Pro/photos
and makes the URL shareable. It is offered in a short URL (db.tt
). This URL is sent to Clean Links, and the resolved URL is sent to TextTool. TextTool uses the replace
method to swap www
with dl
. It then takes that output and adds the Markdown elements (
).
Here are each of the x-success
parameters URL-decoded.
This is encoded once:
clean-links://x-callback-url/clean?url=[clipboard]&retParam=text&x-success=texttool%3A%2F%2Fx-callback-url%2Ftransform%3Fmethod%3Dreplace%26find%3Dwww%26replace%3Ddl%26x-success%3Dtexttool%253A%252F%252Fx-callback-url%252Ftransform%253Ftext%253D%255B%255Boutput%255D%255D%2526method%253Daffix%2526prefix%253D!%25255B%25255D%252528%2526suffix%253D%252529
This is encoded twice:
texttool://x-callback-url/transform?method=replace&find=www&replace=dl&x-success=texttool%3A%2F%2Fx-callback-url%2Ftransform%3Ftext%3D%5B%5Boutput%5D%5D%26method%3Daffix%26prefix%3D!%255B%255D%2528%26suffix%3D%2529
This is encoded three times:
texttool://x-callback-url/transform?text=[[output]]&method=affix&prefix=!%5B%5D%28&suffix=%29
And actually the Markdown elements are encoded in the above action:
prefix=