Pages

2010-07-28

Google Tasks interface case study

UPDATE 2010-09-20: New version at http://privacylog.blogspot.com/2010/09/updated-google-tasks-api.html

Here is the API for Google Tasks. It only supports your default list and it's read-only. And for free, it emails your task list to you. (This mail WILL go to your spam folder)
#!/bin/bash
cd $HOME

curl https://www.google.com/accounts/ClientLogin \
-d Email=YOURUSERNAME@gmail.com \
-d Passwd=YOURPASS \
-d source=privacylog \
-d service=goanna_mobile > token

AUTH=$(sed -n 's/Auth=/auth=/p' token)
HEADER="Authorization: GoogleLogin $AUTH"
URL="https://mail.google.com/tasks/ig"
curl --header "$HEADER" "$URL" > tasks

grep -o "\"\(name\|task_date\|notes\)\":\"[^\"]*\"" tasks > list

mail -s "Your tasks" YOURUSERNAME@gmail.com < list

rm token tasks list

If you want to have that to run daily at 7am, save that script to ~/googletasks.sh and run:
chmod 700 ~/googletasks.sh
crontab -l > ~/tmpcron
echo "0 7 * * * $HOME/googletasks.sh" >> ~/tmpcron
crontab ~/tmpcron
rm ~/tmpcron

Update 2010-08-12: Made code a litte more readable, thanks to a note from Sandstrp, see comments.