使用net_growl php类和growlforwindows,我们可以生成推送通知。我已经从netgrowl测试了以下php代码,一切正常。但是作为新手,我不知道如何将通知推送到本地Intranet网络中的特定客户端。
require_once 'Net/Growl/Autoload.php';
$notifications = array(
'GROWL_NOTIFY_STATUS' => array(
'display' => 'Status',
),
'GROWL_NOTIFY_PHPERROR' => array(
'icon' => 'http://www.laurent-laville.org/growl/images/firephp.png',
'display' => 'Error-Log'
)
);
$appName = 'PHP App Example using GNTP';
$password = '';
$options = array(
'protocol' => 'gntp',
'timeout' => 15,
'AppIcon' => 'http://www.laurent-laville.org/growl/images/Help.png',
);
try {
$growl = Net_Growl::singleton($appName, $notifications, $password, $options);
$name = 'GROWL_NOTIFY_STATUS';
$title = 'Congratulation';
$description = 'You have successfully installed PEAR/Net_Growl.';
$growl->publish($name, $title, $description);
$name = GROWL_NOTIFY_PHPERROR;
$title = 'New Error';
$description = 'You have a new PHP error in your script.';
$options = array(
'priority' => Net_Growl::PRIORITY_HIGH,
);
$growl->publish($name, $title, $description, $options);
$name = GROWL_NOTIFY_STATUS;
$title = 'Welcome';
$description = "Welcome in PHP/GNTP world ! \n"
. "New GNTP protocol add icon support.";
$options = array(
'icon' => 'http://www.laurent-laville.org/growl/images/unknown.png',
'sticky' => false,
);
$growl->publish($name, $title, $description, $options);
} catch (Net_Growl_Exception $e) {
echo 'Caught Growl exception: ' . $e->getMessage() . PHP_EOL;
}
当我运行上述代码时,咆哮声通知会显示在计算机桌面上。为了从其他客户端获得相同的消息,我在其他客户端计算机上安装了growlforwindows,并在我的计算机上的grol中添加了每个IP地址。客户端的咆哮声中也启用了来自其他计算机的订阅通知。但是我不知道如何使用php类将通知推送到特定的客户端计算机,根据我的理解,该类不提供传递客户端IP地址的选项。任何在使用net_growl方面有丰富经验的人,我真的需要您的帮助。