Source for file gntpAdapterSocketCallbacks.php
Documentation is available at gntpAdapterSocketCallbacks.php
* Socket callbacks example
* that send notifications to Growl using the new GNTP/1.0 protocol
* Callbacks are sent back to the sending application
* when an action is taken in response to a notification.
* @author Laurent Laville <pear@laurent-laville.org>
* @author Bertrand Mansion <bmansion@mamasam.com>
* @license http://www.opensource.org/licenses/bsd-license.php BSD
* @version SVN: Release: 2.7.0
* @link http://growl.laurent-laville.org/
* @since File available since Release 2.0.0b2
require_once 'Net/Growl/Autoload.php';
* Callback function when notification response is returned
* @param string $result Notification-Callback-Result: header, result
* [CLICKED|CLOSED|TIMEDOUT] | [CLICK|CLOSE|TIMEOUT]
* @param string $context Notification-Callback-Context: header, result
* from the original request
* @param string $type Notification-Callback-Context-Type: header, result
* from the original request
* @param string $timestamp Notification-Callback-Timestamp: header, result
* The date and time the callback occurred
function cbNotify($result, $context, $type, $timestamp)
"Notification Callback Result => %s: %s (%s) at %s \n\n",
$result, $context, $type, $timestamp
// Notification Type definitions
define('GROWL_NOTIFY_STATUS', 'STATUS');
define('GROWL_NOTIFY_PHPERROR', 'PHPERROR');
// define a PHP application that sends notifications to Growl
$appName = 'PEAR/Net_Growl ' . basename(__FILE__ , '.php');
'icon' => 'http://www.laurent-laville.org/growl/images/firephp.png',
'AppIcon' => 'http://www.laurent-laville.org/growl/images/Help.png',
'debug' => dirname(__FILE__ ) . DIRECTORY_SEPARATOR .
$title = 'Congratulation';
$description = 'You have successfully installed PEAR/Net_Growl.';
'CallbackContext' => 'this is my context',
'CallbackContextType' => 'STRING',
'CallbackFunction' => 'cbNotify'
$growl->publish ($name, $title, $description, $options);
$description = 'You have a new PHP error in your script.';
$growl->publish ($name, $title, $description, $options);
$description = "Welcome in PHP/GNTP world ! \n"
. "New GNTP protocol add icon support.";
'icon' => 'http://www.laurent-laville.org/growl/images/unknown.png',
$growl->publish ($name, $title, $description, $options);
echo 'Caught Growl exception: ' . $e->getMessage () . PHP_EOL;
Documentation generated on Tue, 29 Jan 2013 18:30:05 +0000 by phpDocumentor 1.4.3. PEAR Logo Copyright © PHP Group 2004.
|