Increase notifications from the web server

I notice that Growl allows you to receive Growl notifications from a website. Has anyone tried to implement this?

If so, in what form did it take? Have you implemented multi-user support? And, can you provide code examples (it is preferable to use C # or Objective-C, but I'm not so fussed)?

Rich

+5
source share
1 answer

There are GNTP (Growl Network Transport Protocol) bindings for different languages, a list of bindings can be found here - this allows you to send notifications, for example, using a PHP script.

UL Growl, , (, -), script, HTTP Growls them. , , UDP, , Growl'ing .

, server.php -PHP ( Net_Growl):

<?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()));
    mark_notifications_as_read();
}
?>

client.py -Python ( gntp):

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

All Articles