PHP code example of waset / short-video-distribution

1. Go to this page and download the library: Download waset/short-video-distribution 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/ */

    

waset / short-video-distribution example snippets


// config/distribute.php (ThinkPHP6 会自动生成)

// 因各平台使用 scope 不一致,所以还是单独定义吧,不会太麻烦,毕竟只定这一次
return [
    // 抖音
    "douyin" => [
        'client_key' => '',
        'client_secret' => '',
        'scope' => [
            'trial.whitelist',,
            'user_info',
            // ...
        ]
    ],
    // ...

    // "平台名" => [
    //     '密钥' => '',
    //     '密码' => '',
    //     '权限' => [
    //         ...
    //     ]
    // ],
];

use Waset\Distribute;

// 获取绑定链接(结果是 url,如有需要自行生成二维码)
// TODO:本插件提供二维码生成方法?
$code =  Distribute::app($model)->oauth()->code($scope, $redirect_uri, $state);

// 获取token
$data =  Distribute::app($model)->oauth()->token($code);
// $data = $data->toArray();

// 获取用户信息
$user_info =  Distribute::app($model)->user()->info($data['access_token'], $data['open_id']);
// $user_info = $user_info->toArray();