如果可能的话,我需要你的帮助,我已经安装了库,我添加了代码,但我不能生成令牌并将其与我的URL连接,
**感谢您的帮助,我很抱歉的错误,这是我第一次在论坛上。
这是将JWT库集成到我的代码中
我希望得到帮助的具体部分在第35行:$response[$i]'file_url']= $video 'file_url'];
这是所需的结果:file_url = https://myvideo.com/video.mp4?token=jwt
我想把一个JWT token连接到file_url。你能指导我如何实现吗?
感谢您的帮助!
代码的相关部分:Codigniter版本3
<?php
require_once '/www/wwwroot/premium.portkks.net/vendor/autoload.php';
use Firebase\JWT\JWT;
$secretKey = "mysecretkey"; // Secret key
// Actual time
$issuedAt = time();
// exp time
$expirationTime = $issuedAt + (3 * 60 * 60); // 3 h
$payload = [
"iat" => $issuedAt, // "Issued at" -
"exp" => $expirationTime // "Expiration time"
];
$jwt = JWT::encode($payload, $secretKey, 'HS256');
?>
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
function get_all_video_by_movie_id($videos_id){
$response = array();
$this->db->order_by('order', $this->video_file_order());
$this->db->where('videos_id',$videos_id);
$query = $this->db->get('video_file');
if($query->num_rows() > 0):
$videos = $query->result_array();
$i = 0;
foreach ($videos as $video):
$response[$i]['video_file_id'] = $video['video_file_id'];
$response[$i]['label'] = strtoupper($video['label']);
$response[$i]['stream_key'] = $video['stream_key'];
$response[$i]['file_type'] = $video['file_source'];
$response[$i]['file_url'] = $video['file_url'];
$response[$i]['subtitle'] = $this->get_all_movie_subtitle($video['video_file_id']);
if($video['file_source'] =='gdrive'):
$response[$i]['file_type'] = 'embed';
//$response[$i]['label'] = 'GOOGLE';
elseif($video['file_source'] =='amazone'):
$response[$i]['file_type'] = 'mp4';
elseif($video['file_source'] =='m3u8'):
$response[$i]['file_type'] = 'hls';
elseif($video['file_source'] =='vimeo'):
$response[$i]['file_type'] = 'embed';
$response[$i]['file_url'] = str_replace('vimeo','player.vimeo',$video['file_url']);
$response[$i]['file_url'] = str_replace('.com/','.com/video/',$response[$i]['file_url']);
endif;
$i++;
endforeach;
endif;
return $response;
}
字符串
这是我想要的结果。这是期望的结果:file_url = https://myvideo.com/video.mp4?token=jwt
1条答案
按热度按时间dced5bon1#
我认为你只需要像这样连接这些值:
字符串