TextExpander bit.ly


/ Published in: AppleScript
Save to your folder(s)

You need to replace [replace_with_bitly_username] and [replace_with_bitly_api_key] to make this snippet work. Test in AppleScript code editor if you're experiencing problems in TextEpander such as the snipped being output instead of the bit.ly URL


Copy this code and paste it in your HTML
  1. set the ClipURL to (the clipboard as string)
  2.  
  3. ignoring case
  4. if ((characters 1 through 4 of ClipURL as string) is not "http") then
  5. return "Malformed URL."
  6. else
  7. set curlCMD to ¬
  8. "curl --stderr /dev/null \"http://bit.ly/api?url=" & ClipURL & "&login=[replace_with_bitly_username]&apiKey=[replace_with_bitly_api_key]" & "\""
  9.  
  10. -- Run the script and get the result:
  11. set tinyURL to (do shell script curlCMD)
  12.  
  13. return tinyURL
  14. end if
  15. end ignoring

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.