четверг, 30 апреля 2009 г.

Twitter in Linux

Simple but suitable example using BASH + ZENITY:


#!/bin/bash
LANG=uk_UA.UTF-8 # convert locale UA to unicode
POST=$(zenity --title "My Twitter bot" --entry --text "В Twitter:" --width 500)
#Getting data
len=`echo "$POST" | wc -c` # getting text length
if [ $len -gt 140 ]; then
zenity --error --text="String too long: $len chars" # if more than 140 chars
POST=$(zenity --title "My Twitter bot" --entry --entry-text "$POST" --text
"You have $len chars, should be less:" --width 500)
#return to edit
fi

TEXT="$POST" #You can add additional options to this text
curl --basic --user login:password --data status="$TEXT" 'http://twitter.com/statuses/update.xml'
-o /dev/null | zenity --progress --title "Sending to Twitter"
--text="$TEXT" --auto-kill --auto-close

#Sending
zenity --info --title "Done" --text "$TEXT - length: $len chars added to twitter"


example source: http://gontsa.livejournal.com/#post-gontsa-33965

Комментариев нет:

Отправить комментарий