ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
IFTTTHandler.php
Go to the documentation of this file.
1<?php
2
3/*
4 * This file is part of the Monolog package.
5 *
6 * (c) Jordi Boggiano <j.boggiano@seld.be>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12namespace Monolog\Handler;
13
15
28{
29 private $eventName;
30 private $secretKey;
31
39 {
40 $this->eventName = $eventName;
41 $this->secretKey = $secretKey;
42
43 parent::__construct($level, $bubble);
44 }
45
49 public function write(array $record)
50 {
51 $postData = array(
52 "value1" => $record["channel"],
53 "value2" => $record["level_name"],
54 "value3" => $record["message"],
55 );
56 $postString = json_encode($postData);
57
58 $ch = curl_init();
59 curl_setopt($ch, CURLOPT_URL, "https://maker.ifttt.com/trigger/" . $this->eventName . "/with/key/" . $this->secretKey);
60 curl_setopt($ch, CURLOPT_POST, true);
61 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
62 curl_setopt($ch, CURLOPT_POSTFIELDS, $postString);
63 curl_setopt($ch, CURLOPT_HTTPHEADER, array(
64 "Content-Type: application/json",
65 ));
66
68 }
69}
An exception for terminatinating execution or to throw for unit testing.
Base Handler class providing the Handler structure.
static execute($ch, $retries=5, $closeAfterDone=true)
Executes a CURL request with optional retries and exception on failure.
Definition: Util.php:32
IFTTTHandler uses cURL to trigger IFTTT Maker actions.
__construct($eventName, $secretKey, $level=Logger::ERROR, $bubble=true)
write(array $record)
{Writes the record down to the log of the implementing handler.void}
Monolog log channel.
Definition: Logger.php:28
const ERROR
Runtime errors.
Definition: Logger.php:57