2011-06-09 80 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