php 请求 youtube 视频不起作用
这段代码有什么问题?
header('Content-type: application/x-shockwave-flash');
$video_id = $_REQUEST['id'];
$content = readfile("http://www.youtube.com/watch?v=$video_id");
echo $content;
为什么这段代码不起作用?代码应该怎样看?
我是这样编辑的:
header('Content-type: application/x-shockwave-flash');
$video_id = $_REQUEST['id'];
$content = readfile("http://www.youtube.com/v/$video_id");
echo $content;
如果我得到 http://localhost/media.php?id=pkyRRD9f0ts< /a> 在浏览器中它可以工作,但是如果我将它添加到 jwplayer 中它就不起作用:(
what is wrong to this code?
header('Content-type: application/x-shockwave-flash');
$video_id = $_REQUEST['id'];
$content = readfile("http://www.youtube.com/watch?v=$video_id");
echo $content;
Why this code is not working? How should look the code?
i've edited like this:
header('Content-type: application/x-shockwave-flash');
$video_id = $_REQUEST['id'];
$content = readfile("http://www.youtube.com/v/$video_id");
echo $content;
and if i get http://localhost/media.php?id=pkyRRD9f0ts in browser it works but if i add it in jwplayer it doesn't work :(
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是因为您正在拉取整个网页,就像在浏览器中查看它一样,而不仅仅是视频文件(YouTube 特别不允许这样做)。
尝试回显嵌入 html 标签。
That's because you're pulling the entire webpage as you would view it in a browser, not just the video file (youtube specifically doesn't allow that).
Try echoing an embed html tag instead.