PHP code example of tongyifan / doubanphp

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

    

tongyifan / doubanphp example snippets



Douban\Douban;

$douban_id = '30458442';
$douban = new Douban($douban_id);

$douban_rating = $douban->douban_rating;


Douban\Douban;
use Douban\Config;

$config = new Config();
// see https://book.cakephp.org/3/en/core-libraries/caching.html for more information.
$config->cache_config = [
    'className' => 'Redis',
    'duration' => '+14 days',
    'prefix' => 'doubanphp_',
    'host' => '127.0.0.1',
    'port' => 6379
];

$imdb_id = 'tt11043632';
$douban = new Douban($imdb_id, null, $config);
$douban_rating = $douban->douban_rating;

// or use numeric IMDb id, but you should add "source".
$imdb_id = '11043632';
$douban = new Douban($imdb_id, 'imdb', $config);
$douban_rating = $douban->douban_rating;