Hey, thanks for your help.
I'm looking to create a script that creates a bitly link to the file every 
time I upload a file using box simpleshare. the app copy's a url to the 
clipboard and sends a growl notification when it is done so I've written a 
script which will take the contents of the clipboard and check it is a url 
and then create a bitly link copy it to the clipboard and notify using 
growl. The script works succesfully the only thing is I want it to trigger 
every time box simpleshare sends a notification so that I automatically get 
a bitly link. I can't seem to get it to trigger.
What am I doing wrong?

-- this sub-routine is used to encode text 
*on* encode_text(this_text, encode_URL_A, encode_URL_B)
*set* *the* standard_characters *to* "abcdefghijklmnopqrstuvwxyz0123456789"
*set* *the* URL_A_chars *to* "$+!'/?;&@=#%><{}[]\"~`^\\|*:"
*set* *the* URL_B_chars *to* ".-_"
*set* *the* acceptable_characters *to* *the* standard_characters
*if* encode_URL_A *is* false *then* *set* *the* acceptable_characters *to* *
the* acceptable_characters & *the* URL_A_chars
*if* encode_URL_B *is* false *then* *set* *the* acceptable_characters *to* *
the* acceptable_characters & *the* URL_B_chars
*set* *the* encoded_text *to* ""
*repeat* *with* this_char *in* this_text
*if* this_char *is* *in* *the* acceptable_characters *then*
*set* *the* encoded_text *to* (*the* encoded_text & this_char)
*else*
*set* *the* encoded_text *to* (*the* encoded_text & encode_char(this_char)) 
*as* *string*
*end* *if*
*end* *repeat*
*return* *the* encoded_text
*end* encode_text

*on* encode_char(this_char)
*set* *the* ASCII_num *to* (*the* *ASCII number* this_char)
*set* *the* hex_list *to* {"0", "1", "2", "3", "4", "5", "6", "7", "8", 
"9", "A", "B", "C", "D", "E", "F"}
*set* x *to* *item* ((ASCII_num *div* 16) + 1) *of* *the* hex_list
*set* y *to* *item* ((ASCII_num *mod* 16) + 1) *of* *the* hex_list
*return* ("%" & x & y) *as* *string*
*end* encode_char



*using terms from* *application* "Growl"
*on* *perform action* with notification
*run*
*end* *perform action*
*end* *using terms from*

*on* *run*
*set* Oauth *to* "*******" *as* *string*
*set* input *to* (*the clipboard* as *string*)
*ignoring* case
*if* (((*characters* 1 *thru* 4 *of* input) *as* *string*) *is not* *equal 
to* "http") *then*
*set* input *to* "http://"; & input
*end* *if*
*set* theurl *to* encode_text(input, true, false)
*set* curlCMD *to* "curl --stderr /dev/null 
\"https://api-ssl.bitly.com/v3/shorten?access_token="; & Oauth & "&longUrl=" 
& theurl & "&format=txt\""
*set* shortURL *to* (*do shell script* curlCMD)
*set the clipboard to* shortURL
*tell* *application* "System Events"
*set* isRunning *to* (*count* *of* (*every* *process* *whose* bundle 
identifier *is* "com.Growl.GrowlHelperApp")) > 0
*end* *tell*
*if* isRunning *then*
*tell* *application* id "com.Growl.GrowlHelperApp"
-- Make a list of all the notification types 
-- that this script will ever send:
*set* *the* allNotificationsList *to* ¬
{"Success!"}
-- Make a list of the notifications 
-- that will be enabled by default.      
-- Those not enabled by default can be enabled later 
-- in the 'Applications' tab of the Growl preferences.
*set* *the* enabledNotificationsList *to* ¬
{"Success!"}
-- Register our script with growl.
-- You can optionally (as here) set a default icon 
-- for this script's notifications.
*register* as application ¬
"Box Bitly" all notifications allNotificationsList ¬
default notifications enabledNotificationsList ¬
-- icon of application "Script Editor"
--       Send a Notification...
*notify* with name ¬
"Success!" title ¬
"Success!" description ¬

"The Bitly link is " & shortURL application name "Box Bitly"

*end* *tell*

*end* *if*

*end* *ignoring*

*end* *run*

                   

-- 
You received this message because you are subscribed to the Google Groups 
"Growl Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/growldiscuss.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to