PHP code example of vision-rhythm / douyin-open-php

1. Go to this page and download the library: Download vision-rhythm/douyin-open-php 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/ */

    

vision-rhythm / douyin-open-php example snippets






const CLIENT_ID = '';
const CLIENT_SECRET = '';

\Visionrhythm\VisionRhythm::setDebug(true); //调试模式   true /false
\Visionrhythm\VisionRhythm::setApiMode('sandbox'); //环境  live 线上,sandbox 沙盒
\Visionrhythm\VisionRhythm::setclientId(CLIENT_ID);    // 设置 id
\Visionrhythm\VisionRhythm::setclientSecret(CLIENT_SECRET);   // secret
\VisionRhythm\VisionRhythm::setRedirectUri(''); //回调地址


$open_id = '';
$access_token = '';

try {

    $userInfo = \VisionRhythm\User::info($open_id, $access_token);
    echo($userInfo)."\r\n";

    $fans = \VisionRhythm\User::fans($open_id, $access_token, 0, 10);
    echo($fans)."\r\n";

    $following = \VisionRhythm\User::following($open_id, $access_token, 0, 10);
    echo($following)."\r\n";

} catch (\Visionrhythm\Error\Base $e) {
    if ($e->getHttpStatus() != null) {
        header('Status: ' . $e->getHttpStatus());
        echo $e->getHttpBody();
    } else {
        echo $e->getMessage();
    }
}



bash
./vendor/bin/phpunit tests/UtilTest.php