问题原因
DiscuzQ 324更新 手机端使用了新增加的V2接口,V2接口没有返回视频的鉴权地址。
解决方法
找到 app\\Api\\Controller\\Threads 下
ListThreadsV2Controller.php
找到
use Discuz\\Base\\DzqController;
下面加上
use Discuz\\Contracts\\Setting\\SettingsRepository;
use Carbon\\Carbon;
use Illuminate\\Support\\Str;
找到
public function main()
上面加上
protected $settings;
public function __construct(SettingsRepository $settings)
{
$this->settings = $settings;
}
找到
$data[\'extension\'] = [
Thread::EXT_VIDEO => ThreadVideo::instance()->getThreadVideo($thread[\'id\'])
];
下面加上
$urlKey = $this->settings->get(\'qcloud_vod_url_key\', \'qcloud\');
$urlExpire = (int) $this->settings->get(\'qcloud_vod_url_expire\', \'qcloud\');
if ($urlKey && $urlExpire && $data[\'extension\'][\'video\'][\'mediaUrl\']) {
$currentTime = Carbon::now()->timestamp;
$dir = Str::beforeLast(parse_url($data[\'extension\'][\'video\'][\'mediaUrl\'])[\'path\'], \'/\') . \'/\';
$t = dechex($currentTime+$urlExpire);
$us = Str::random(10);
$sign = md5($urlKey . $dir . $t . $us);
$data[\'extension\'][\'video\'][\'mediaUrl\'] = $data[\'extension\'][\'video\'][\'mediaUrl\'] . \'?t=\' . $t . \'&us=\'. $us . \'&sign=\'.$sign;
}
ResourceThreadV2Controller.php
找到
use Discuz\\Base\\DzqController;
下面加上
use Discuz\\Contracts\\Setting\\SettingsRepository;
use Carbon\\Carbon;
use Illuminate\\Support\\Str;
找到
public $relation = [
\'rewardedUsers\' => Order::ORDER_TYPE_REWARD, //打赏的人
\'paidUsers\' => Order::ORDER_TYPE_THREAD, //付费用户
\'onlookers\' => Order::ORDER_TYPE_ONLOOKER //围观用户
];
下面加
protected $settings;
找到
UserFollowRepository $userFollow
后面加上
,SettingsRepository $settings
找到
$data[\'images\'] = [];
下面加上
$urlKey = $this->settings->get(\'qcloud_vod_url_key\', \'qcloud\');
$urlExpire = (int) $this->settings->get(\'qcloud_vod_url_expire\', \'qcloud\');
找到
$data[\'threadVideo\'] = $thread->threadVideo ?? [];
下面加上
if ($urlKey && $urlExpire && $data[\'threadVideo\'][\'mediaUrl\']) {
$currentTime = Carbon::now()->timestamp;
$dir = Str::beforeLast(parse_url($data[\'threadVideo\'][\'mediaUrl\'])[\'path\'], \'/\') . \'/\';
$t = dechex($currentTime+$urlExpire);
$us = Str::random(10);
$sign = md5($urlKey . $dir . $t . $us);
$data[\'threadVideo\'][\'mediaUrl\'] = $data[\'threadVideo\'][\'mediaUrl\'] . \'?t=\' . $t . \'&us=\'. $us . \'&sign=\'.$sign;
}
找到
$data[\'threadAudio\'] = $thread->threadAudio ?? [];
下面加上
if ($urlKey && $urlExpire && $data[\'threadAudio\'][\'mediaUrl\']) {
$currentTime = Carbon::now()->timestamp;
$dir = Str::beforeLast(parse_url($data[\'threadAudio\'][\'mediaUrl\'])[\'path\'], \'/\') . \'/\';
$t = dechex($currentTime+$urlExpire);
$us = Str::random(10);
$sign = md5($urlKey . $dir . $t . $us);
$data[\'threadAudio\'][\'mediaUrl\'] = $data[\'threadAudio\'][\'mediaUrl\'] . \'?t=\' . $t . \'&us=\'. $us . \'&sign=\'.$sign;
}
搞定 修改代码 注意缩进
附上修改的文件
© 版权声明
1. 资源都是经过站长或作者收集测试修改后发布分享。如若转载请在文内以超链形式注明狐狸库文章出处,谢谢合作!
2. 本站除原创内容,其余所有内容均收集自互联网,仅限用于学习和研究目的,本站不对其内容的合法性承担任何责任。如有版权内容,请通知我们或作者删除,其版权均归原作者所有,本站虽力求保存原有版权信息,但因众多资源经多次转载,已无法确定其真实来源,或已将原有信息丢失,所以敬请原作者谅解!
3. 本站用户所发布的一切资源内容不代表本站立场,并不代表本站赞同其观点和对其真实性负责,若您对本站所载资源作品版权归属存有异议,请留言附说明联系邮箱,我们将在第一时间予以处理 ,同时向您表示歉意!为尊重作者版权,请购买原版作品,支持您喜欢的作者,谢谢!
4. 本站一律禁止以任何方式发布或转载任何违法的相关信息,访客如有发现请立即向站长举报;本站资源文件大多存储在云盘,如发现链接或图片失效,请联系作者或站长及时更新。
THE END
请登录后查看评论内容