小编bir*_*use的帖子

OpenSSL 错误消息:错误:14095126 读取时意外 eof

说明
此错误:

file_get_contents(): SSL operation failed with code 1. OpenSSL Error messages: error:14095126:SSL routines:ssl3_read_n:unexpected eof while reading
Run Code Online (Sandbox Code Playgroud)

返回时:

$file = file_get_contents($url['url'], false, stream_context_create($arrContextOptions));
Run Code Online (Sandbox Code Playgroud)

重现步骤

视频下载:


https://www.youtube.com/watch?v=r5NzAksjfDI

提取视频ID:

$video_id = $yt->extractVideoId(implode($url));
Run Code Online (Sandbox Code Playgroud)

获取可下载的网址

$links = $yt->getDownloadLinks($video_id, $selector = 'video');
Run Code Online (Sandbox Code Playgroud)

获取指定视频质量等的数组键。

$arrayindex = array_search('mp4, video, 1080p, audio', array_column($links, 'format'));
Run Code Online (Sandbox Code Playgroud)

将 $url 设置为数组

$url = $links[$arrayindex];
Run Code Online (Sandbox Code Playgroud)

禁用 SSL

$arrContextOptions=array( "ssl"=>array( "verify_peer"=>false, "verify_peer_name"=>false, ), );
Run Code Online (Sandbox Code Playgroud)

从url获取文件

$video = file_get_contents($url['url'], false, stream_context_create($arrContextOptions));
Run Code Online (Sandbox Code Playgroud)

将视频发送回前端

return view('convert', [ 'url' => $url['url'], 'quality' => $url['format'], ]);
Run Code Online (Sandbox Code Playgroud)

预期行为:
视频被下载
实际行为: …

php youtube laravel

4
推荐指数
2
解决办法
3013
查看次数

标签 统计

laravel ×1

php ×1

youtube ×1