This is how you post a tweet to Twitter using Applescript and a clever little cURL call.
property theUser : "usernamehere" -- your username
property thePassword : "passwordhere" -- your password
on postTweet(theUser, thePassword, theMessage)
set TwitterUpdate to "/usr/bin/curl" & ¬
" --user " & quoted form of (theUser & ":" & thePassword) & ¬
" --data status=" & quoted form of encodeURL(theMessage) & ¬
" http://twitter.com/statuses/update.xml"
-- Now try sending the Tweet to Twitter
set TwitterResponse to do shell script TwitterUpdate
if TwitterResponse contains "Could not authenticate" then
return "Tweet failed to post. Your username or password may be incorrect, or Twitter might be expieriencing difficulties."
else
return "Tweet successfully posted"
end if
end postTweet
on encodeURL(someURL)
return do shell script "/usr/bin/python -c '" & ¬
"from sys import argv; " & ¬
"from urllib import quote; " & ¬
"print quote(unicode(argv[1], \\"utf8\\"))' " & quoted form of someURL
end encodeURL
postTweet (theUser, thePassword, "I'm posting this tweet through Applescript! Awesome!")