Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to growl from php

Tags:

php

growl

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?

like image 449
Radek Avatar asked Dec 31 '25 12:12

Radek


1 Answers

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.');
like image 154
Tyler Hall Avatar answered Jan 03 '26 03:01

Tyler Hall



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!