-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMessages.php
More file actions
25 lines (22 loc) · 825 Bytes
/
Messages.php
File metadata and controls
25 lines (22 loc) · 825 Bytes
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
<?php
require_once 'clases/answers.php';
require_once 'clases/messages.class.php';
$_answers = new answers;
$_messages = new messages;
if($_SERVER['REQUEST_METHOD'] == 'POST'){
$post_body = file_get_contents("php://input");//recibir los datos
$datos = json_decode($post_body,true);
if(isset($datos["token"])){
$keywordsList = $_messages->postMessage($post_body);
//Devolvemos una respuesta
header('Content-type: application/json');
echo json_encode($keywordsList);
http_response_code(200);
}else{
$sendMessage = $_messages->sendBotResponse($post_body);
header('Content-type: application/json');
echo json_encode($sendMessage);
http_response_code(200);
}
}
?>