how to growl from php
I am trying to send growl notifications from PHP. The receiving computer is OSX and I am able to receive local notifications as well as notifications from ruby scripts executed from other computers. No password is set.
I use the php-growl class and my code looks like this:
<?php
require 'class.growl.php';
$ip_address = '10.0.0.210';
$growl = new Growl($ip_address, '');
// Register with the remote machine.
// You only need 开发者_如何学Pythonto do this once.
$growl -> register();
// Send your message
$growl -> notify('PHP Growl', 'Title', 'Here\'s the body text');
?>
My script was registered in growl locally, but no notification was displayed. I can't find any PHP errors in my log files either.
Any suggestions on how to send/receive growls without using a password?
The problem isn't using an empty password. Before you can send a Growl notification, you first need to register the notifications that you plan to send.
<?PHP
$growl = new Growl($ip_address);
// Adding and registering your notifications with Growl
// only needs to be done once per computer. Growl will
// remember your app after this.
$growl->addNotification('Notification Name');
$growl->addNotification('Another Notification');
$growl->register();
// Send a notification
$growl->notify('Notification Name', 'Some Title', 'Some message to display');
// Send a second notification
$growl->notify('Another Notification', 'Another Title', 'Something useful I hope.');
精彩评论