diff options
Diffstat (limited to 'app/Anime.php')
| -rw-r--r-- | app/Anime.php | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/app/Anime.php b/app/Anime.php index 5fd4db3..76eca09 100644 --- a/app/Anime.php +++ b/app/Anime.php @@ -126,4 +126,39 @@ class Anime extends Model { return $data; } + public function getEnhancementFromAnilist() { + + $query = ' + query($id: Int!) { + Media(idMal: $id, type: ANIME) { + title { + userPreferred + } + description + hashtag + } + } + '; + $variables = [ + "id" => $this->mal_id, + ]; + + // Make the HTTP Api request + try { + $http = new \GuzzleHttp\Client; + $response = $http->post('https://graphql.anilist.co', [ + 'json' => [ + 'query' => $query, + 'variables' => $variables, + ] + ]); + + $data = json_decode( $response->getBody() )->data->Media; + } catch (\Exception $e) { + echo "Problem with Guzzle connecting to Anilist on anime: (" . $this->mal_id . ")\n"; + return ""; + } + return $data; + + } } |
