completeCurlRequest($ch); } public function getCharacterByName($server, $name) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'https://xivapi.com/character/search?name='.$name.'&server='.$server); $characterResults = $this->completeCurlRequest($ch); if ($characterResults->Pagination->Results === 0) throw new NotFoundHttpException(); return $this->getCharacterById($characterResults->Results[0]->ID); } public function getFreeCompanyById($id) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'https://xivapi.com/freecompany/'.$id.'?data=FCM'); return $this->completeCurlRequest($ch); } public function getFreeCompanyByName($server, $name) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'https://xivapi.com/freecompany/search?name='.$name.'&server='.$server); $characterResults = $this->completeCurlRequest($ch); if ($characterResults->Pagination->Results === 0) throw new NotFoundHttpException(); return $this->getFreeCompanyById($characterResults->Results[0]->ID); } private function completeCurlRequest($ch) { curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $result = curl_exec($ch); if (curl_errno($ch)) { throw new Exception('Error:' . curl_error($ch)); } curl_close($ch); return json_decode($result); } }