public function createPost($args) { if (!isset($args["eventId"])) { return $this->io->badRequest("Network ID was missing", $args); } if (!isset($args["accessToken"])) { return $this->io->badRequest("Access token was missing", $args); } if (!isset($args["postContent"])) { return $this->io->badRequest("Post content was missing", $args); } if (!isset($args["latitude"])) { return $this->io->badRequest("Latitude was missing", $args); } if (!isset($args["longitude"])) { return $this->io->badRequest("Longitude was missing", $args); } $query = "INSERT INTO post (user_id, event_id, post_content, post_latitude, post_longitude, post_timestamp) VALUES (:user, :event, :content, :lat, :lon, UTC_TIMESTAMP)"; $bindings = []; $bindings[":user"] = $this->io->getUserId($args); $bindings[":event"] = $args["eventId"]; $bindings[":content"] = $args["postContent"]; $bindings[":lat"] = $args["latitude"]; $bindings[":lon"] = $args["longitude"]; $results = $this->io->queryDB($args, $query, $bindings); if ($results["data"] > 0) { $results["meta"]["status"] = 201; $results["meta"]["message"] = "Post was created"; $postId = $this->io->getLastInsertedID(); $mediaIO = new MediaIO($this->io); $mediaIO->saveMediaForPost($args, $postId); } return $results; }