2011-06-09 102 views
3

我想从PHP发送咆哮通知。接收计算机是OSX,我能够接收本地通知以及从其他计算机执行的ruby脚本的通知。没有设置密码。如何从php咆哮

我使用php-growl类和我的代码如下所示:

<?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'); 
?> 

我的剧本是在咆哮本地注册,但不会显示任何通知。我在我的日志文件中也找不到任何PHP错误。

关于如何发送/接收的任何建议咆哮没有使用密码

+6

'echo'Grrrrrrrr!';';-) – ceejayoz 2011-06-09 02:43:42

回答

3

该问题未使用空密码。在发送低吼通知之前,您首先需要注册您计划发送的通知。

<?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.'); 
+0

的作品。大。谢谢。 – Radek 2011-06-09 23:19:59

+0

让我困惑的是,我的注册中的注册应用程序是'PHP Growl',但在我的脚本中我必须注册'notification'。我使用了http://clickontyler.com/php-growl/中的示例代码 – Radek 2011-06-09 23:32:00