views:

677

answers:

1

Hi,

I notice that Growl allows for the possibility of Growl notifications from a website. Has anyone tried implementing this?

If so, what form did it take? Did you implement multi user support? And, can you provide any code examples (C# or Objective-C would preferable but I'm not that fussed)?

Rich

+2  A: 

netgrowl.php was written for this very purpose also. ReGrowl by the same author may be of use also (it receives Growl UDP packets and relays them to all machines on your local network)

I wouldn't trust Growl's UDP system, but rather write a server that receives and stores notifications via HTTP (as a tiny web app), and a local script that routinely grabs any new messages and Growls them. Not complicated at all, will be more reliable than UDP, and can queue up messages when your Growl'ing machine is powered-off or unreachable. Shouldn't take long to implement

Basically, server.php in pseudo-PHP:

<?php
if($_GET['action'] == "store"){
    $title = $_POST['title'];
    $message = $_POST['message'];
    $password = sha1($_POST['password']);
    if($password == "..."){
        store_in_database(sanitise($title), sanitise($message);
    }
} else {
    print(json_encode(get_notifications_from_database()));
}
?>

client.py in pseudo-Python:

while 1:
time.sleep(60):
    data = urllib.urlopen("http://myserver.com/server.php?action=get&amp;password=blah").read()
    for line in data:
        notif = json.decode(line)
        growl.alert(notif['title'], notif['message'])
dbr