• TwitNews – Post to Twitter from NetNewsWire

    Just mashed up a quick applescript to post the currently selected news item in NetNewsWire to Twitter. The code is highly influenced from TwiTunes, (which posts the current track on iTunes to Twitter) and the Shorten URL script from iconmaster. So all credits goes to them.

    By default, the contents of the tweet is set to the title of the news item and the URL is shortened using is.gd and you can easily customize it.

    The script needs you to save your Twitter login credentials in your keychain or else you will get an error. To do this, tell Safari to save your login details to Keychain while you login to Twitter or you can do it manually in the keychain app by selecting ‘New password item’ and set Keychain item name as http://twitter.com and fill in your Twitter username and password in the following fields.

    Installation

    Download the script TwitNews, uncompress and drop it into ~/Library/Application Support/NetNewsWire/Scripts. Now you can access the script from the scripts menu on NetNewsWire.

    Code

    If you want to have a look at the code:

    tell application "NetNewsWire"
    if index of selected tab = 0 then
    -- We're looking at headlines, so just get the headline URL
    set feed_url to URL of selectedHeadline
    set feed_title to title of selectedHeadline
    else
    -- We're looking at a web view tab, so we need to know which tab
    set i to index of selected tab
    set i to i + 1
    -- Get the tab's URL
    set URL_list to URLs of tabs
    set title_list to titles of tabs
    set feed_url to item i of URL_list
    set feed_title to item i of title_list
    end if
    -- Build the GET request for the is.gd API
    set feed_url to "http://is.gd/api.php?longurl=" & feed_url
    -- Submit the GET request and copy the results to clipboard
    set cmd to "curl " & feed_url
    set feed_url to (do shell script cmd)
    end tell

    -- change the status message to your liking here:
    set tweet to feed_title & " " & feed_url

    -- let the user edit
    display dialog "Edit your Twitter status" with title "TwitNews" default answer tweet cancel button 1 default button 2 buttons {"Cancel", "Send"}
    set tweet to (text returned of result)

    -- get login from keychain
    tell application "Keychain Scripting"
    set twitter_key to first Internet key of current keychain whose server is "twitter.com"
    set twitter_login to quoted form of (account of twitter_key & ":" & password of twitter_key)
    end tell

    -- post to twitter
    set twitter_status to quoted form of ("status=" & tweet)
    set results to do shell script "curl --user " & twitter_login & " --data-binary " & twitter_status & " http://twitter.com/statuses/update.json"

    Hope you find this useful and feel free to make any changes as you need.

    UPDATE: You might want to check this post to assign a keyboard shortcut to the script.

    UPDATE: There is an updated version available with some new features. Please see this post.


    31 Responses to “TwitNews – Post to Twitter from NetNewsWire”

    1. sami Says:

      many thanks, was looking for something like this

    2. Barry Says:

      Thanks.
      Is there any chance I could convince you to make one for Pingfm as well?

    3. dab Says:

      thank you so much! just what i was looking for!

    4. David Says:

      Thanks for the script! It works perfectly!

      I was actually planning out how to write one of these, and ran across yours, so thanks for saving me a bit of time.

    5. Liew Cheon Fong Says:

      it works great. thanks!

    6. eddie_e65 Says:

      …Thanks!

      I was looking for a plug in like this script!!

    7. vandy Says:

      I have two twitter accounts, how can I get to choose which one it posts to?

    8. Krzysztof Maj Says:

      Hello,
      very useful script! I was looking for something like that. Thanks a lot!

    9. Gulumbit Says:

      Thanks for the script – very helpful. For some reason I couldn’t get it to work with my Keychain but managed a workaround.

      For any others, who like me, have no scripting skills, this is the edit I used:

      Deleted:
      – get login from keychain
      tell application “Keychain Scripting”
      set twitter_key to first Internet key of current keychain whose server is “twitter.com”
      set twitter_login to quoted form of (account of twitter_key & “:” & password of twitter_key)
      end tell

      Added instead:
      – Set Twitter username and password
      set twitter_username to “enter_your_twitter_username”
      set twitter_password to “enter_your_twitter_password”
      set twitter_login to quoted form of (twitter_username & “:” & twitter_password)

    10. Cameron Reilly Says:

      I’ve been using (and loving) the TwitNews script but now it seems to have stopped working. I’m wondering if the NetNewsWire upgrades have buggered it? Anyone else experiencing problems all of a sudden?

    11. Tinu Cleatus Says:

      @Cameron I just checked this with the NNW beta and it works fine. Maybe you should update to the latest NetNewsWire beta. I’m using 3.2b24.

    12. Crash7800 Says:

      Used Twitter App in facebook to send this on as my Facebook status. WIN! Thanks! :) Any way to map this to a hotkey?

    13. TwitNews Keyboard Shortcut | making things work Says:

      [...] time ago, I wrote an applescript ‘TwitNews‘ for posting link to news items to Twitter from NetNewsWire. Many people seemed to find it [...]

    14. Cameron Reilly Says:

      @Tinu, I’m running what I believe is the latest version of NNW (3.2b.25) and I’ve just uninstalled and reinstalled the script but it’s still not posting. The pop-up box appears, looks fine, I hit “send”, the box disappears, but no tweet is sent. It’s strange.

    15. How to Post Links to Twittter from Netnewswire | Robin Malau Dot Com Says:

      [...] thanks to this post, we, the-not-so-script-developer, can also post to twitter from our favorite desktop news reader [...]

    16. Patrix Says:

      Awesome. I had the same problem as Cameron. But I deleted the Twitter entries in keychain, uninstalled the script and tried again. Worked like a charm. Thanks a lot for this script.

      My Twitter followers will not be inundated with ‘interesting’ links. Bwhahaha!

    17. Patrix Says:

      I got this error msg when I tried posting my second link – http://bit.ly/4H0ETd.

      Any idea of what’s happening?

    18. De NetNewsWire a Twitter Says:

      [...] Via: making things work Script: TwitNews [...]

    19. Flanker Says:

      Gulumbit: Thanks, your code-fix made this work like a charm! Excellent :)

    20. Sigurdur Armannsson Says:

      Thanks very much for this script and Gulumbit for the additional fix. Works like a charm with NNW and TweetDeck. Tweeted about this script of course.

    21. Koodoz Design Says:

      Thanks Tinu for this great script.

      FYI, this doesn’t seem to work with 10.5.8 or 10.6+. However, Gulumbit’s small hack seems to do the trick! Thanks :)

      The one thing I noticed though, was when copying the new code into the script editor, the quotation marks (“ ”) that are displayed within the code snippet will make the script unable to compile/work. So if anyone has troubles with the code that Gulumbit has provided, the likely problem is that you need to change all instances of “ ” to ” “.

    22. Where are the new/updated Twitter Clients? | SchackNetz Says:

      [...] have a “Tweet this” button, but lucky for me I found a really nice solution over at making things work. They have a neat little script that enables NetNewsWire to tweet – and even provide a way to [...]

    23. Post to Pinboard in NetNewsWire | BlogHalt.com (Pre-Launch) Says:

      [...] script for Readability in NetNewsWire. I simply adapted it for Pinboard. Similarly, you can use the TwitNews script for posting to Twitter from NetNewsWire. I use these three tools – Pinboard Tagging, Readability, and TwitNews – within [...]

    24. Post News to Twitter from NetNewsWire – Aceh Mac Club - Mac OS X Says:

      [...] isi scriptnya dari web sumber twitnews : ?Download twitnews.txt1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 [...]

    25. Twitnews update | making things work Says:

      [...] back I posted an applescript to tweet news items in NetNewsWire to your twitter followers and seems like many [...]

    26. gitano Says:

      Thanks! Works very well.

    27. Tinu Cleatus Says:

      There is an updated version of Twitnews available with some new features. Please see this post http://blog.tinucleatus.com/?p=346

    28. Learn by Exploring Your Tools Says:

      [...] use NetNewsWire for my feed reading purposes. I like to share interesting links I find on Twitter. Tinu Cleatus whipped up the perfect Apple Script that made sharing the page I was reading a keyboard shortcut away. But not quite perfect. I use [...]

    29. Manage Your RSS Feed In Mac With NetNewsWire – Make Tech Easier Says:

      [...] to Instapaper, add them to Delicious, or send them to a blogging application. I have even found an AppleScript that let’s you tweet articles; quite handy for sharing. You can even save posts directly to [...]

    30. Quản lý RSS Feed trong Mac với NetNewsWire « Net24h.info Says:

      [...] Delicious, hoặc gửi chúng đến một ứng dụng blog. Bạn có thể phát hiện ở AppleScript rằng, nó cho phép tweet các bài báo; một hành động khá thú vị cho việc chia [...]

    31. Quản lý RSS Feed trong Mac với NetNewsWire « Le Viet Thanh Professional's Blog Says:

      [...] Delicious, hoặc gửi chúng đến một ứng dụng blog. Bạn có thể phát hiện ở AppleScript rằng, nó cho phép tweet các bài báo; một hành động khá thú vị cho việc chia [...]

    Leave a Reply