Skip to content

Instantly share code, notes, and snippets.

@freeatnet
Created May 19, 2010 08:04
Show Gist options
  • Save freeatnet/406081 to your computer and use it in GitHub Desktop.
Save freeatnet/406081 to your computer and use it in GitHub Desktop.
A _very_ simple script that allows sending a file line-by-line as your tweets. Deletes line sent from file. Easy to hook up to Cron. Uses Basic auth.
#!/bin/bash
# Usage: twitlinesender.py <lines.txt>
API_URL="http://api.twitter.com/1"
API_USER="YOUR_TWITTER_USERNAME"
API_PASSWORD="YOUR_TWITTER_PASSWORD"
value=`cat $1 | head -n 1`
encoded_value=`python -c "import urllib; print urllib.quote('''$value''')"`
echo $value
echo $encoded_value
if [ ! -z $value ]
then
curl -X POST -d "status=$encoded_value" -u $API_USER:$API_PASSWORD $API_URL/statuses/update.xml
tmpfile=`mktemp`
cat $1 | tail -n +2 > $tmpfile
cat $tmpfile > $1
else
echo "Empty string as status, not sending"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment