Posted By

nick108 on 09/14/10


Tagged

applescript productivity bitly textexpander


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

steviraab


TextExpander bit.ly


 / Published in: AppleScript
 

You need to replace [replacewithbitlyusername] and [replacewithbitlyapi_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

  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  

You need to login to post a comment.