mirror of
https://github.com/Seldaek/monolog.git
synced 2025-08-07 21:56:31 +02:00
CS fixes, refs #623
This commit is contained in:
@@ -20,45 +20,44 @@ use Monolog\Logger;
|
|||||||
*/
|
*/
|
||||||
class IFTTTHandler extends AbstractProcessingHandler
|
class IFTTTHandler extends AbstractProcessingHandler
|
||||||
{
|
{
|
||||||
protected $_eventName;
|
private $eventName;
|
||||||
protected $_secretKey;
|
private $secretKey;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $eventName The name of the IFTTT Maker event that should be triggered
|
* @param string $eventName The name of the IFTTT Maker event that should be triggered
|
||||||
* @param string $secretKey A valid IFTTT secret key
|
* @param string $secretKey A valid IFTTT secret key
|
||||||
* @param integer $level The minimum logging level at which this handler will be triggered
|
* @param integer $level The minimum logging level at which this handler will be triggered
|
||||||
* @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not
|
* @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not
|
||||||
*/
|
*/
|
||||||
public function __construct($eventName, $secretKey, $level = Logger::ERROR, $bubble = true)
|
public function __construct($eventName, $secretKey, $level = Logger::ERROR, $bubble = true)
|
||||||
{
|
{
|
||||||
$this->_eventName = $eventName;
|
$this->eventName = $eventName;
|
||||||
$this->_secretKey = $secretKey;
|
$this->secretKey = $secretKey;
|
||||||
|
|
||||||
parent::__construct($level, $bubble);
|
parent::__construct($level, $bubble);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function write(array $record)
|
public function write(array $record)
|
||||||
{
|
{
|
||||||
$postData = array(
|
$postData = array(
|
||||||
"value1" => $record["channel"],
|
"value1" => $record["channel"],
|
||||||
"value2" => $record["level_name"],
|
"value2" => $record["level_name"],
|
||||||
"value3" => $record["message"]
|
"value3" => $record["message"]
|
||||||
);
|
);
|
||||||
$postString = json_encode($postData);
|
$postString = json_encode($postData);
|
||||||
|
|
||||||
$ch = curl_init();
|
$ch = curl_init();
|
||||||
|
curl_setopt($ch, CURLOPT_URL, "https://maker.ifttt.com/trigger/" . $this->eventName . "/with/key/" . $this->secretKey);
|
||||||
|
curl_setopt($ch, CURLOPT_POST, true);
|
||||||
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||||
|
curl_setopt($ch, CURLOPT_POSTFIELDS, $postString);
|
||||||
|
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
|
||||||
|
"Content-Type: application/json"
|
||||||
|
));
|
||||||
|
|
||||||
curl_setopt($ch, CURLOPT_URL, "https://maker.ifttt.com/trigger/" . $this->_eventName . "/with/key/" . $this->_secretKey);
|
Curl\Util::execute($ch);
|
||||||
curl_setopt($ch, CURLOPT_POST, 1);
|
}
|
||||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
}
|
||||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $postString);
|
|
||||||
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
|
|
||||||
"Content-Type: application/json"
|
|
||||||
));
|
|
||||||
|
|
||||||
Curl\Util::execute($ch);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
Reference in New Issue
Block a user