ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 
12 namespace Monolog\Handler;
13 
14 use Monolog\Logger;
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 
67  Curl\Util::execute($ch);
68  }
69 }
const ERROR
Runtime errors.
Definition: Logger.php:57
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
__construct($eventName, $secretKey, $level=Logger::ERROR, $bubble=true)
IFTTTHandler uses cURL to trigger IFTTT Maker actions.
Create styles array
The data for the language used.
if($session===NULL) $postData