📦 国内最全的短视频平台 SDK
- PHP >= 8.0.0
- Composer >= 2.0
- ThinkPHP >= 6.0
- TODO...
composer require waset/short-video-distribution
// config/distribute.php (ThinkPHP6 会自动生成)
<?php
// 因各平台使用 scope 不一致,所以还是单独定义吧,不会太麻烦,毕竟只定这一次
return [
// 抖音
"douyin" => [
'client_key' => '',
'client_secret' => '',
'scope' => [
'trial.whitelist',,
'user_info',
// ...
]
],
// ...
// "平台名" => [
// '密钥' => '',
// '密码' => '',
// '权限' => [
// ...
// ]
// ],
];
抖音 => 'douyin'
今日头条 => 'toutiao'
西瓜视频 => 'xigua'
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();