Skip to content

Instantly share code, notes, and snippets.

@swalberg
Created August 26, 2012 16:31
Show Gist options
  • Save swalberg/3481512 to your computer and use it in GitHub Desktop.
Save swalberg/3481512 to your computer and use it in GitHub Desktop.
#!/usr/bin/php -q
<?php
/**
* Example that send notifications to Growl using the new GNTP/1.0 protocol
*
* PHP version 5
*
* @category Networking
* @package Net_Growl
* @author Laurent Laville <[email protected]>
* @author Bertrand Mansion <[email protected]>
* @license http://www.opensource.org/licenses/bsd-license.php BSD
* @version SVN: Release: @package_version@
* @link http://growl.laurent-laville.org/
* @since File available since Release 0.9.0
*/
require_once 'Net/Growl/Autoload.php';
// Notification Type definitions
define('GROWL_NOTIFY_STATUS', 'GROWL_NOTIFY_STATUS');
define('GROWL_NOTIFY_PHPERROR', 'GROWL_NOTIFY_PHPERROR');
// define a PHP application that sends notifications to Growl
$appName = 'Asterisk';
$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'
)
);
$password = 'test';
$options = array(
'host' => '192.168.1.171',
'protocol' => 'tcp', 'port' => Net_Growl::GNTP_PORT, 'timeout' => 15,
'AppIcon' => 'http://www.laurent-laville.org/growl/images/Help.png',
'debug' => dirname(__FILE__) . DIRECTORY_SEPARATOR . 'netgrowl.log'
);
try {
$growl = Net_Growl::singleton($appName, $notifications, $password, $options);
$growl->register();
$name = GROWL_NOTIFY_STATUS;
$title = 'Phone Call';
$description = "Phone call from $argv[1]";
$options = array();
$growl->notify($name, $title, $description, $options);
} catch (Net_Growl_Exception $e) {
echo 'Caught Growl exception: ' . $e->getMessage() . PHP_EOL;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment