1<?php 2/** 3 * URL callbacks example 4 * that send notifications to Growl using the new GNTP/1.0 protocol 5 * 6 * The callback url will be opened in the user's default browser. 7 * Unlike socket callbacks, URL callbacks are only triggered if the notification 8 * is clicked (CLICK|CLICKED), not for CLOSE|CLOSED or TIMEOUT|TIMEDOUT actions. 9 * 10 * PHP version 5 11 * 12 * @category Networking 13 * @package Net_Growl 14 * @author Laurent Laville <pear@laurent-laville.org> 15 * @author Bertrand Mansion <bmansion@mamasam.com> 16 * @license http://www.opensource.org/licenses/bsd-license.php BSD 17 * @version SVN: Release: 2.7.0 18 * @link http://growl.laurent-laville.org/ 19 * @since File available since Release 2.0.0b2 20 */ 21 22require_once 'Net/Growl/Autoload.php'; 23 24// Notification Type definitions 25define('GROWL_NOTIFY_STATUS', 'STATUS'); 26define('GROWL_NOTIFY_PHPERROR', 'PHPERROR'); 27 28// define a PHP application that sends notifications to Growl 29 30$app = new Net_Growl_Application( 31 'PEAR/Net_Growl ' . basename(__FILE__, '.php'), 32 array( 33 GROWL_NOTIFY_STATUS => array( 34 'display' => 'Status', 35 ), 36 37 GROWL_NOTIFY_PHPERROR => array( 38 'icon' => 'http://www.laurent-laville.org/growl/images/firephp.png', 39 'display' => 'Error-Log' 40 ) 41 ), 42 'mamasam' 43); 44 45 46try { 47 $growl = Net_Growl::singleton( 48 $app, 49 null, null, 50 array( 51 'protocol' => 'gntp', 52 'AppIcon' => 'http://www.laurent-laville.org/growl/images/Help.png', 53 'encryptionAlgorithm' => 'AES', 54 'passwordHashAlgorithm' => 'SHA256', 55 'debug' => dirname(__FILE__) . DIRECTORY_SEPARATOR . 56 basename(__FILE__, '.php') . '.log' 57 ) 58 ); 59 $growl->register(); 60 61 $name = GROWL_NOTIFY_STATUS; 62 $title = 'Congratulation'; 63 $description = "You have successfully installed PEAR/Net_Growl."; 64 $options = array( 65 'ID' => 123456, 66 'CallbackContext' => 'this is my context', 67 'CallbackContextType' => 'STRING', 68 'CallbackTarget' => 'http://growl.laurent-laville.org/parseUrl.php' 69 . '?hello=world', 70 'sticky' => true, 71 ); 72 $growl->publish($name, $title, $description, $options); 73 74 $name = GROWL_NOTIFY_PHPERROR; 75 $title = 'New Error'; 76 $description = 'You have a new PHP error in your script.'; 77 $options = array( 78 'priority' => Net_Growl::PRIORITY_HIGH, 79 ); 80 $growl->publish($name, $title, $description, $options); 81 82 $name = GROWL_NOTIFY_STATUS; 83 $title = 'Welcome'; 84 $description = "Welcome in PHP/GNTP world ! \n" 85 . "New GNTP protocol add icon support."; 86 $options = array( 87 'icon' => 'http://www.laurent-laville.org/growl/images/unknown.png', 88 'sticky' => false, 89 ); 90 $growl->publish($name, $title, $description, $options); 91 92} catch (Net_Growl_Exception $e) { 93 echo 'Caught Growl exception: ' . $e->getMessage() . PHP_EOL; 94} 95