| Conditions | 1 |
| Paths | 1 |
| Total Lines | 20 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 10 | public function dispatch(MessageInterface $message) |
||
| 11 | { |
||
| 12 | // Get the dispatch and message data from the message. |
||
| 13 | $dispatchData = $message->getDispatchData(); |
||
| 14 | $messageData = $message->getMessageData(); |
||
| 15 | |||
| 16 | $msg = $messageData['body']; |
||
| 17 | $url = $dispatchData['webhook']; |
||
| 18 | |||
| 19 | // @TODO: Build from message data. |
||
| 20 | $payload = 'payload={"text": "' . $msg . '", "icon_emoji": ":ghost:"}'; |
||
| 21 | |||
| 22 | $ch = curl_init(); |
||
| 23 | curl_setopt($ch, CURLOPT_POST, true); //set how many paramaters to post |
||
| 24 | curl_setopt($ch, CURLOPT_URL, $url); |
||
| 25 | curl_setopt($ch, CURLOPT_POSTFIELDS, $payload); |
||
| 26 | |||
| 27 | curl_exec($ch); //execute and get the results |
||
| 28 | curl_close($ch); |
||
| 29 | } |
||
| 30 | } |