我正在尝试从PHP发送咆哮通知。接收计算机是OSX,我能够接收本地通知以及从其他计算机执行的ruby脚本的通知。没有设置密码。
我使用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');
?>
我的脚本在本地注册了growl,但未显示任何通知。我在日志文件中找不到任何PHP错误。
有关如何不使用密码发送/接收咆哮的任何建议?
答案 0 :(得分:3)
问题是没有使用空密码。在发送Growl通知之前,您首先需要注册您计划发送的通知。
<?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.');