3

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 to 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?

Jeffrey
  • 1,239
  • 8
  • 15
Radek
  • 13,813
  • 52
  • 161
  • 255

1 Answers1

3

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.');
Tyler Hall
  • 46
  • 1
  • 3
  • what confused me is that registered application in my comp is `PHP Growl` but in my script I have to register `notification`. I used the sample code from http://clickontyler.com/php-growl/ – Radek Jun 09 '11 at 23:32