-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWebHook.php
More file actions
42 lines (30 loc) · 1.01 KB
/
WebHook.php
File metadata and controls
42 lines (30 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php
require('./class/RequestDialogFlow.php');
require('./class/RequestMyZap.php');
class WebHook
{
function __construct() {
$this->url = $_SERVER['REQUEST_URI'];
$routeExist = file_exists('./'.$this->url.'.php');
$this->checkRoute($routeExist);
$this->dialoflow = new RequestDialogFlow;
$this->myzap = new RequestMyZap;
}
function handler()
{
$receive = file_get_contents('php://input');
$data = json_decode($receive);
if($data->wook == "RECEIVE_MESSAGE" and $data->type = "text" and $data->isGroupMsg == false){
$send = $this->dialoflow->requestDefault($data->content);
$myzap = $this->myzap->requestDefault($receive, $send);
return $myzap;
}
}
function checkRoute($routeExist)
{
if($routeExist === false or $_SERVER['REQUEST_METHOD'] === 'GET') {
echo json_encode(["error" => true, 'message' => 'Route does not exist.'], 404);die;
}
}
}
?>