Net_Growl
[ class tree: Net_Growl ] [ index: Net_Growl ] [ all elements ]

Source for file udpAdapter.php

Documentation is available at udpAdapter.php

  1. <?php
  2. /**
  3.  * Example that send notifications to Growl using the old UDP protocol
  4.  *
  5.  * PHP version 5
  6.  *
  7.  * @category Networking
  8.  * @package  Net_Growl
  9.  * @author   Laurent Laville <pear@laurent-laville.org>
  10.  * @author   Bertrand Mansion <bmansion@mamasam.com>
  11.  * @license  http://www.opensource.org/licenses/bsd-license.php  BSD
  12.  * @version  SVN: Release: 2.7.0
  13.  * @link     http://growl.laurent-laville.org/
  14.  * @since    File available since Release 0.9.0
  15.  */
  16.  
  17. require_once 'Net/Growl/Autoload.php';
  18.  
  19. // Notification Type definitions
  20. define('GROWL_NOTIFY_STATUS',   'STATUS');
  21. define('GROWL_NOTIFY_PHPERROR''PHPERROR');
  22.  
  23. // define a PHP application that sends notifications to Growl
  24. $appName 'PEAR/Net_Growl ' basename(__FILE__'.php');
  25.  
  26. $notifications = array(
  27.     GROWL_NOTIFY_STATUS => array(),
  28.     GROWL_NOTIFY_PHPERROR => array()
  29. );
  30.  
  31. try {
  32.     $growl Net_Growl::singleton($appName$notifications);
  33.     $growl->register();
  34.  
  35.     $name        GROWL_NOTIFY_STATUS;
  36.     $title       'Congratulation';
  37.     $description 'You have successfully installed PEAR/Net_Growl.';
  38.     $growl->publish($name$title$description);
  39.  
  40.     $name        GROWL_NOTIFY_PHPERROR;
  41.     $title       'New Error';
  42.     $description 'You have a new PHP error in your script.';
  43.     $options     = array(
  44.         'sticky'   => true,
  45.         'priority' => Net_Growl::PRIORITY_HIGH,
  46.     );
  47.     $growl->publish($name$title$description$options);
  48.  
  49.     $name        GROWL_NOTIFY_STATUS;
  50.     $title       'Welcome';
  51.     $description "Welcome in PHP/Growl world ! \n"
  52.                  . "Old UDP protocol did not support icons.";
  53.     $growl->publish($name$title$description);
  54.  
  55.     var_export($growl);
  56.  
  57. catch (Net_Growl_Exception $e{
  58.     echo 'Caught Growl exception: ' $e->getMessage(. PHP_EOL;
  59. }

Documentation generated on Tue, 29 Jan 2013 18:30:06 +0000 by phpDocumentor 1.4.3. PEAR Logo Copyright © PHP Group 2004.