00001: <?php
00002: /**
00003: * Example that send notifications to Growl using the old UDP protocol
00004: *
00005: * PHP version 5
00006: *
00007: * @category Networking
00008: * @package Net_Growl
00009: * @author Laurent Laville <pear@laurent-laville.org>
00010: * @author Bertrand Mansion <bmansion@mamasam.com>
00011: * @license http://www.opensource.org/licenses/bsd-license.php BSD
00012: * @version CVS: Release: @package_version@
00013: * @link http://growl.laurent-laville.org/
00014: * @since File available since Release 0.9.0
00015: */
00016:
00017: require_once 'Net/Growl.php';
00018:
00019: // Notification Type definitions
00020: define('GROWL_NOTIFY_STATUS', 'GROWL_NOTIFY_STATUS');
00021: define('GROWL_NOTIFY_PHPERROR', 'GROWL_NOTIFY_PHPERROR');
00022:
00023: // define a PHP application that sends notifications to Growl
00024:
00025: $appName = 'PHP App Example using UDP';
00026: $notifications = array(
00027: GROWL_NOTIFY_STATUS => array(),
00028: GROWL_NOTIFY_PHPERROR => array()
00029: );
00030:
00031: $password = 'mamasam';
00032: $options = array('host' => '192.168.1.2');
00033:
00034: try {
00035: $growl = Net_Growl::singleton($appName, $notifications, $password, $options);
00036: $growl->register();
00037:
00038: $name = GROWL_NOTIFY_STATUS;
00039: $title = 'Congratulation';
00040: $description = 'Congratulation! You are successfull install PHP/NetGrowl.';
00041: $growl->notify($name, $title, $description);
00042:
00043: $name = GROWL_NOTIFY_PHPERROR;
00044: $title = 'PHP Error';
00045: $description = 'You have a new PHP error in your script P at line N';
00046: $options = array(
00047: 'sticky' => true,
00048: 'priority' => Net_Growl::PRIORITY_HIGH,
00049: );
00050: $growl->notify($name, $title, $description, $options);
00051:
00052: $name = GROWL_NOTIFY_STATUS;
00053: $title = 'Welcome';
00054: $description = "Welcome in PHP/Growl world ! \n"
00055: . "Old UDP protocol did not support icons.";
00056: $growl->notify($name, $title, $description);
00057:
00058: var_export($growl);
00059:
00060: } catch (Net_Growl_Exception $e) {
00061: echo 'Caught Growl exception: ' . $e->getMessage() . PHP_EOL;
00062: }
00063: ?>