Guest User

Untitled

a guest
Apr 10th, 2018
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.26 KB | None | 0 0
  1. 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
  2. 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
  3.  
  4. Application error
  5. An error occurred in the application and your page could not be served.
  6. If you are the application owner, check your logs for details.
  7.  
  8. <?php
  9.  
  10. $dbServername = '******************';
  11. $dbUsername = '******************';
  12. $dbPassword = '******************';
  13. $dbName = '******************';
  14. $conn = mysqli_connect($dbServername, $dbUsername, $dbPassword, $dbName);
  15.  
  16. header('Content-Type: application/json');
  17. $method = $_SERVER['REQUEST_METHOD'];
  18.  
  19. if ($method == 'POST') {
  20. $requestBody = file_get_contents('php://input');
  21. $json = json_decode($requestBody);
  22.  
  23. $action = $json->result->action;
  24. $first_name = $json->result->contexts[0]->parameters->{'given-name'};
  25. $last_name = $json->result->contexts[0]->parameters->{'last-name'};
  26. $lifespan = $json->result->contexts[0]->lifespan;
  27.  
  28. $sql = "SELECT * FROM family WHERE name LIKE '%$first_name%$last_name%';";
  29. $result = mysqli_query($conn, $sql);
  30. $resultCheck = mysqli_num_rows($result);
  31. if ($resultCheck > 0) {
  32. while ($row = mysqli_fetch_assoc($result)) {
  33. $person = $row;
  34. }
  35.  
  36. switch ($action) {
  37. case 'Name':
  38. $speech = "$first_name is my" . $person["name"] . ".";
  39. break;
  40. case 'Location':
  41. $speech = "$first_name is living in {$person["location"]}.";
  42. break;
  43. default:
  44. $speech = "Please ask me something more relevant to my family";
  45. break;
  46. }
  47. } else {
  48.  
  49. $speech = "Sorry, $first_name $last_name is not a member of my family.";
  50. }
  51.  
  52. $response = new stdClass();
  53. $response->speech = $speech;
  54. $response->displayText = $speech;
  55. $response->source = "agent";
  56. echo json_encode($response);
  57. } else {
  58. echo "Method not allowed";
  59. }
  60. ?>
Add Comment
Please, Sign In to add comment