7.1.1. | The response times are slow | |||
You can reduced timeout period on a stream (socket) to connect/read. Default is 30 secondes, like php.ini default_socket_timeout directive. Example 7.1. Set timetout to 15 secondes <?php
require_once 'Net/Growl/Autoload.php';
$notifications = array(
'GROWL_NOTIFY_PHPERROR'
);
$appName = 'PHP App Example using GNTP';
$password = 'mamasam';
$app = new Net_Growl_Application(
$appName,
$notifications,
$password
);
$options = array(
'host' => '127.0.0.1',
'protocol' => 'tcp',
'port' => Net_Growl::GNTP_PORT,
'timeout' => 15
);
$growl = Net_Growl::singleton($app, null, null, $options);
$growl->register();
?>
| ||||
7.1.2. | Notifications are not displayed | |||
| ||||
7.1.3. | Net_Growl is not really verbose | |||
To known what MIME messages are sent and received from Growl, activate the verbose mode. Give a valid path to a filename on debug option. Example 7.3. Activate the debug mode <?php
require_once 'Net/Growl/Autoload.php';
$notifications = array(
'GROWL_NOTIFY_PHPERROR'
);
$appName = 'PHP App Example using GNTP';
$password = 'mamasam';
$options = array(
'host' => '127.0.0.1',
'protocol' => 'tcp',
'port' => Net_Growl::GNTP_PORT,
'debug' => dirname(__FILE__) . DIRECTORY_SEPARATOR . 'netgrowl.log'
);
try {
$growl = Net_Growl::singleton($appName, $notifications, $password, $options);
$growl->register();
} catch (Net_Growl_Exception $e) {
echo 'Caught Growl exception: ' . $e->getMessage() . PHP_EOL;
}
?> | ||||
7.1.4. | My favorite application icons are not shown | |||
| ||||
7.1.5. | How to detect error with new version 2.1 | |||
GNTP specialized response are now returned with version 2.1.0 (or greater). If you want to catch an error, test status code after each register() or notify() method. See Net_Growl_Response::getStatus Example 7.4. Use the Net_Growl_Response object <?php
require_once 'Net/Growl/Autoload.php';
$notifications = array(
'GROWL_NOTIFY_PHPERROR'
);
$appName = 'PHP App Example using GNTP';
$password = 'mamasam';
$options = array(
'host' => '127.0.0.1',
'protocol' => 'tcp',
'port' => Net_Growl::GNTP_PORT,
'debug' => dirname(__FILE__) . DIRECTORY_SEPARATOR . 'netgrowl.log'
);
try {
$growl = Net_Growl::singleton($appName, $notifications, $password, $options);
$resp = $growl->register();
if ($resp->getStatus() != 'OK') {
die($resp);
}
} catch (Net_Growl_Exception $e) {
echo 'Caught Growl exception: ' . $e->getMessage() . PHP_EOL;
}
?> |