iPhone notifications from the command line
notifo --subscribe_user some_notifo_username
notifo --subscribe_user some_notifo_username_1 some_notifo_username2 ...
echo hi | notifo some_notifo_username
echo hi | notifo --title "MySQL Connection Error" --uri "http://www.nerdkits.com/" some_notifo_username1 some_notifo_username2 ...
w | notifo --title "Who's logged in" some_notifo_username1 some_notifo_username2 ...
import notifo
notifo.subscribe_user('some_notifo_username')
notifo.send_notification('some_notifo_username', 'This is a message!', 'My Title', 'http://www.nerdkits.com/')
When in subscribe_user
mode, a list of Notifo usernames is read, and one call is made to try to subscribe each.
When in send_notification
mode, the program reads from stdin
until EOF and uses this as the message body. The title, URI, and a list of recipient usernames can be specified on the command line.
Notifo is a web service which lets you push notifications to a mobile device. As of 4/23/2010, an iPhone client is available, and Android and Blackbery are said to be coming soon.
When a user has the iPhone client installed, and a notification is pushed to them, they will typically receive the message within 15 seconds or so if they have network connectivity either via WiFi or cellular data.
This script lets you push notifications to your Notifo subscribers (including yourself) from the command line, and as such may be particularly useful from cron jobs, etc. It also serves as a Python library for interfacing with Notifo.
Get a Notifo service provider account.
Per this blog post, a user account may also work fine (though it won't support subscribe_user
calls, and you can only send to yourself).
You'll also want to get a Notifo user account and install the iPhone client.
Download it.
Right click to save: Download the script, or:
wget http://www.nerdkits.com/files/notifo/notifo-0.1.py
Rename it.
If you want it to work as notifo
from the command line, then:
mv notifo-0.1.py notifo
Placing it into a directory in your path, such as ~/bin/
(if enabled), may be useful.
If you want to use it as a Python library, then make sure you call it notifo.py
.
Mark as executable.
chmod a+x notifo
Edit the file with your Notifo service provider authentication info.
Near the top of the file, you'll see two lines:
NOTIFO_USER = 'YOUR_NOTIFO_USERNAME_HERE'
NOTIFO_KEY = 'YOUR_NOTIFO_API_KEY_GOES_HERE'
Put your Notifo username and API key (not the same as your password!) between the quotes, and save.
Try it.
./notifo --subscribe_user your_notifo_username
*
echo "Hello world" | ./notifo --title "First test" your_notifo_username
* This will fail (error 1101: Invalid Credentials) if you've used a user account API key instead of a service provider API key. But that's OK -- you can still send a message to yourself.
sudo apt-get install python-simplejson