You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

51 lines
1.6 KiB

<?php
include('httpful.phar');
require_once("../../config.php");
header("Content-Type: application/json");
if(isset($_GET["conversationID"])) {
$id = intval($_GET['conversationID']);
$uri = 'https://escolamodelows.interlegis.leg.br/api/v1/fale_conosco/mensagens';
// $uri = 'http://localhost:3000/api/v1/fale_conosco/mensagens';
$response = \Httpful\Request::post($uri)
->sendsJson()
->body('{"conversation_id": "' . $id . '"}')
->send();
} elseif(isset($_REQUEST["addMessage"])) {
$id = intval($_GET['addMessage']);
$cpf = $USER->username;
$description = $_GET['description'];
$uri = 'https://escolamodelows.interlegis.leg.br/api/v1/fale_conosco/adicionar';
// $uri = 'http://localhost:3000/api/v1/fale_conosco/adicionar';
$response = \Httpful\Request::post($uri)
->sendsJson()
->body('{
"name": "' . $USER->username . '",
"email": "' . $USER->email . '",
"cpf": "' . $cpf . '",
"description": "' . $description . '",
"is_student": false,
"conversation_id": "' . $id . '"
}')
->send();
} elseif(isset($_REQUEST["schoolInitials"])) {
$was_answered = intval($_GET['answered'])== 0 ? 'false':'true';
$was_answered = trim($was_answered, '"');
$uri = 'https://escolamodelows.interlegis.leg.br/api/v1/fale_conosco/conversa';
// $uri = 'http://localhost:3000/api/v1/fale_conosco/conversa';
$response = \Httpful\Request::post($uri)
->sendsJson()
->body(
'{
"school_initials": "SSL",
"page" : "1",
"limit": "2000",
"was_answered": '. $was_answered .'
}')
->send();
}
$data=$response->body;
echo json_encode($data);