Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 2018-04-10T09:09:09.853483+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=POST path="/" host=************.herokuapp.com request_id=************ fwd="************" dyno= connect= service= status=503 bytes= protocol=https
- 2018-04-10T09:09:56.037642+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=************.herokuapp.com request_id=************ fwd="************" dyno= connect= service= status=503 bytes= protocol=https
- Application error
- An error occurred in the application and your page could not be served.
- If you are the application owner, check your logs for details.
- <?php
- $dbServername = '******************';
- $dbUsername = '******************';
- $dbPassword = '******************';
- $dbName = '******************';
- $conn = mysqli_connect($dbServername, $dbUsername, $dbPassword, $dbName);
- header('Content-Type: application/json');
- $method = $_SERVER['REQUEST_METHOD'];
- if ($method == 'POST') {
- $requestBody = file_get_contents('php://input');
- $json = json_decode($requestBody);
- $action = $json->result->action;
- $first_name = $json->result->contexts[0]->parameters->{'given-name'};
- $last_name = $json->result->contexts[0]->parameters->{'last-name'};
- $lifespan = $json->result->contexts[0]->lifespan;
- $sql = "SELECT * FROM family WHERE name LIKE '%$first_name%$last_name%';";
- $result = mysqli_query($conn, $sql);
- $resultCheck = mysqli_num_rows($result);
- if ($resultCheck > 0) {
- while ($row = mysqli_fetch_assoc($result)) {
- $person = $row;
- }
- switch ($action) {
- case 'Name':
- $speech = "$first_name is my" . $person["name"] . ".";
- break;
- case 'Location':
- $speech = "$first_name is living in {$person["location"]}.";
- break;
- default:
- $speech = "Please ask me something more relevant to my family";
- break;
- }
- } else {
- $speech = "Sorry, $first_name $last_name is not a member of my family.";
- }
- $response = new stdClass();
- $response->speech = $speech;
- $response->displayText = $speech;
- $response->source = "agent";
- echo json_encode($response);
- } else {
- echo "Method not allowed";
- }
- ?>
Add Comment
Please, Sign In to add comment