Go Back   The Apple Blog Community > Community > General Banter
Register Social Groups iSpy Members List Search Today's Posts Mark Forums Read FAQ

General Banter All off-topic chitty chat

View Poll Results: Do you use Twitter?
Yes 5 26.32%
No 11 57.89%
What's Twitter? (read on) 3 15.79%
Voters: 19. You may not vote on this poll

Reply
 
LinkBack Thread Tools Search this Thread
03-22-2007   #31 (permalink)
Concierge
 
divigation's Avatar
 
Join Date: Dec 2006
Location: Houston
Posts: 754
divigation is on a distinguished road
Send a message via AIM to divigation Send a message via Skype™ to divigation
So getting rather annoyed with Twitterific and Twitter Post not working, I decided to dive into messing with the Twitter API via Terminal to see if I couldn't bypass the apps. For simply posting to Twitter via the command line:

$curl -u username:password --form status="Message text here." http://twitter.com/statuses/update.xml

And voila, your message is posted. Although it takes a while because Twitter's server sucks and can't handle the traffic of its popularity. As for reading posts, I am still trying to get that correct, but I don't know enough programming to write a good script to output exactly what I would like, so at current I am running the following in GeekTool and having it post on my desktop, refreshing every minute (or at least a minute after the two or three minutes it takes to fetch the data from Twitter's crappy server). So here is the code:

$curl -u username:password http://twitter.com/statuses/friends_timeline.xml|grep "<text>\|<relative_created_at>\|<name>"

The possible fields you can choose to display are:
<created_at> standard time stamp instead of relative that I am using
<screen_name> screen name instead of full name that I am using
<location> user's location
<description> user's description of self
<profile_image_url> the profile image, good if you were going to use this to write an actual app, useless for the command line
<url> user's homepage

Additionally, you can check 3 other lists rather than the Friends and You timeline:
http://twitter.com/statuses/public_timeline.xml
http://twitter.com/statuses/friends.xml
http://twitter.com/statuses/followers.xml
The first is obviously the public timeline, the second and third show a list of each of your friends (or followers) and their last post with the same tags as the timelines. If you have growlnotify installed, you could then pipe whatever feed into a growl notification, but you would want to modify your grep to grab the first instance or the first two, rather than spitting out your whole list (-m3 after grep to tell it to print three lines).

Anyhow, I am trying to clean this up so that I can get a solid output, though after a few minutes the tags just disappear to my eyes. although if you are running this in Terminal, rather than GeekTool, you can add --color=always between grep and the patterns and the tags will show up bold and red, making it easy to look past them. Hopefully there will be other feedback on cleaning this up and simplifying it. Of course adding an alias to your .profile for whatever command you want to use would be greatly useful. twitter is now my command for checking my timeline feed.

It is ridiculous that I wasted time today messing with this! Perhaps posting all of the information here somehow justifies it a bit.

_________________________

So thanks to Equin I have here is the code to clean out the tags

sed -e :a -e 's/<[^>]*>//g;/</N;//ba'

So the line I am now refreshing in GeekTool is:

$curl -u username:password http://twitter.com/statuses/friends_timeline.xml|grep "<text>\|<relative_created_at>\|<name>"|sed -e :a -e 's/<[^>]*>//g;/</N;//ba'

The result is a clean string of text, a thing of beauty! Then utilizing GeekTool I also have a similar string which is then piped into growlnotify every five minutes, giving me the last post every five minutes. Between the desktop and the growl reminders I am able to stay on top of my friends posts without any problems.
__________________
17" MBP 2.33GHz C2D 3GB RAM 160GB HDD
TV [courtesy of the fine folks at TAB] & iPhone

Last edited by divigation; 03-22-2007 at 09:04 PM. Reason: Updated info thanks to Equin's command of Unix
divigation is offline   Reply With Quote
Sponsored Links
03-22-2007   #32 (permalink)
Concierge
 
divigation's Avatar
 
Join Date: Dec 2006
Location: Houston
Posts: 754
divigation is on a distinguished road
Send a message via AIM to divigation Send a message via Skype™ to divigation
@mdmunoz - What were you using to test out Twitter and Growl earlier?
__________________
17" MBP 2.33GHz C2D 3GB RAM 160GB HDD
TV [courtesy of the fine folks at TAB] & iPhone
divigation is offline   Reply With Quote
03-23-2007   #33 (permalink)
Concierge
 
divigation's Avatar
 
Join Date: Dec 2006
Location: Houston
Posts: 754
divigation is on a distinguished road
Send a message via AIM to divigation Send a message via Skype™ to divigation
If you want the result of some real coding to do what I am doing, TweetyPy was released today by Muffin Research Labs. They created a TextMate bundle for Twitter that allows you to post from TM. TweetyPy allows you to post to Twitter and to get your friends timeline or the public timeline from the command line. This util is written in python to format all of the text into clean columns. Works wonderfully with GeekTool and is much cleaner than my solution.
__________________
17" MBP 2.33GHz C2D 3GB RAM 160GB HDD
TV [courtesy of the fine folks at TAB] & iPhone
divigation is offline   Reply With Quote
03-24-2007   #34 (permalink)
Concierge
 
mdmunoz's Avatar
 
Join Date: Nov 2006
Location: Davis, CA
Posts: 643
mdmunoz has disabled reputation
Send a message via AIM to mdmunoz
Quote:
Originally Posted by divigation View Post
@mdmunoz - What were you using to test out Twitter and Growl earlier?
I was playing around with this script. It lets you post to twitter from Quicksilver, and returns your twitter post as a growl notification.

I wanted to use it to as a way to update the status of blog posts, but the Javascript Twitter provides takes forever to load, even if the content hasn't changed. Boo.
mdmunoz is offline   Reply With Quote
03-24-2007   #35 (permalink)
Concierge
 
divigation's Avatar
 
Join Date: Dec 2006
Location: Houston
Posts: 754
divigation is on a distinguished road
Send a message via AIM to divigation Send a message via Skype™ to divigation
Not sure what you use for your website, but I currently have mine set up to check my Twitter RSS feed, seems to be fast even when Twitter isn't.
__________________
17" MBP 2.33GHz C2D 3GB RAM 160GB HDD
TV [courtesy of the fine folks at TAB] & iPhone
divigation is offline   Reply With Quote
04-18-2007   #36 (permalink)
rom
Inventory Control Specialist
 
Join Date: Dec 2006
Posts: 53
rom is on a distinguished road
Just in case, add me, too!
rom is offline   Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT -6. The time now is 10:28 PM.




Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0 RC5
© 2004-2008