PHP code example of skywing / douban-resource

1. Go to this page and download the library: Download skywing/douban-resource 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/ */

    

skywing / douban-resource example snippets



use Skywing\Douban\Douban;

// init  

$douban = new Douban();  

// book's isbn10/isbn13 code  

$isbn = '9787115473899';

// get a book entity  

try {
    $book = $douban->getBook($isbn);
    if ($book) {
        // use as an array
        $book->toArray();
        
        // or get json format
        $book->toJSON();
        
        // also, get property directly is allowed
        $book->getTitle();
        $book->getPrice();
    }
} catch (\Exception $exception) {
    // handle exception
}