1. Go to this page and download the library: Download magnum357i/myanimelist-api library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
// Create object
$mal = new \MyAnimeList\Search\Anime( 'bleach' );
// Send request
$mal->sendRequestOrGetData();
// Is not 404 page or (cache enabled) cache file exists
if ( $mal->isSuccess() ) {
echo $mal->results;
echo $mal->link();
}
else {
echo 'No data.';
}
// Create object
$mal = new \MyAnimeList\Search\Manga( 'baka to test to shoukanjuu' );
// Send request
$mal->sendRequestOrGetData();
// Is not 404 page or (cache enabled) cache file exists
if ( $mal->isSuccess() ) {
echo $mal->results;
echo $mal->link();
}
else {
echo 'No data.';
}
// Create object
$mal = new \MyAnimeList\Search\Character( 'yugi' );
// Send request
$mal->sendRequestOrGetData();
// Is not 404 page or (cache enabled) cache file exists
if ( $mal->isSuccess() ) {
echo $mal->results;
echo $mal->link();
}
else {
echo 'No data.';
}
// Create object
$mal = new \MyAnimeList\Search\People( 'yui' );
// Send request
$mal->sendRequestOrGetData();
// Is not 404 page or (cache enabled) cache file exists
if ( $mal->isSuccess() ) {
echo $mal->results;
echo $mal->link();
}
else {
echo 'No data.';
}
// Create object
$mal = new \MyAnimeList\Widget\NewAnime;
// Send request
$mal->sendRequestOrGetData();
// Is not 404 page or (cache enabled) cache file exists
if ( $mal->isSuccess() ) {
echo $mal->tvnew;
echo $mal->tvcontinuing;
echo $mal->ona;
echo $mal->ova;
echo $mal->movie;
echo $mal->special;
echo $mal->link();
}
else {
echo 'No data.';
}
// Create object
$mal = new \MyAnimeList\Widget\UpcomingAnime;
// Send request
$mal->sendRequestOrGetData();
// Is not 404 page or (cache enabled) cache file exists
if ( $mal->isSuccess() ) {
echo $mal->tv;
echo $mal->ona;
echo $mal->ova;
echo $mal->movie;
echo $mal->special;
echo $mal->unknown;
echo $mal->link();
}
else {
echo 'No data.';
}
// Create object
$mal = new \MyAnimeList\Widget\AnimeCalendar;
// Send request
$mal->sendRequestOrGetData();
// Is not 404 page or (cache enabled) cache file exists
if ( $mal->isSuccess() ) {
echo $mal->monday;
echo $mal->tuesday;
echo $mal->wednesday;
echo $mal->thursday;
echo $mal->friday;
echo $mal->saturday;
echo $mal->sunday;
echo $mal->link();
}
else {
echo 'No data.';
}
// Page
$folders = \MyAnimeList\Builder\AbstractPage::$folders
$type = 'anime'
$mal = new \MyAnimeList\Page\Anime( 20, new \MyCustomCache( $type, $folders ) );
// Search
$folders = \MyAnimeList\Builder\AbstractSearch::$folders
$type = 'anime'
$mal = new \MyAnimeList\Search\Anime( 'naruto', new \MyCustomCache( $type, $folders ) );
// Widget
$folders = \MyAnimeList\Builder\AbstractWidget::$folders
$type = 'animecalendar'
$mal = new \MyAnimeList\Widget\AnimeCalendar( new \MyCustomCache( $type, $folders ) );
// Create object
$mal = new \MyAnimeList\Page\Manga( 1 );
// Reverse
$mal->config()->reversename = TRUE;
// Send request
$mal->sendRequestOrGetData();
// Test
echo $mal->authors;
// Output
// reverse name option is true: Naoki Urasawa
// reverse name option is false: Urasawa, Naoki
// Create object
$mal = new \MyAnimeList\Page\Manga( 1 );
// Use bigger images
$mal->config()->bigimages = TRUE;
// Send request
$mal->sendRequestOrGetData();
// Test
var_dump( $mal->staff );
// Create object
$mal = new \MyAnimeList\Page\Anime( 1 );
// Enable cache
$mal->config()->enablecache = TRUE;
$mal->config()->expiredbyday = 5;
$mal->cache()->setPath( ROOT_PATH . '/upload' );
// Send request
$mal->sendRequestOrGetData();
// Test
echo $mal->titleEnglish;
echo $mal->poster;
// Note
// Backs up the values you use.
// So, based on the above values, this will be create a file named 1.json
// and inside of the file writes the english title of the anime.
// Also a poster named 1.jpg is saved.
// After all, it will return false even if you call another value until the cache expires.
// Please don't forget this.
// Create object
$mal = new \MyAnimeList\Page\Manga( 20 );
// Send request
$mal->sendRequestOrGetData();
// Get all data
$mal->scanAvailableValues();
// Print data
var_dump( $mal->output() );
// Create object
$mal = new \MyAnimeList\Page\People( 1 );
// A sample setting
$mal->config()->setCurlOption( 'Mozilla/5.0 (Windows NT 5.1; rv:31.0) Gecko/20100101 Firefox/31.0', 'USERAGENT' );
// Send request
$mal->sendRequestOrGetData();
// Create object
$mal = new \MyAnimeList\Page\Anime( 285 );
// Send request
$mal->sendRequestOrGetData();
$mal->setLimit( 3 ); // works for all indexed arrays
var_dump( $mal->voice );