嵌入 Youtube 视频的最佳方式是什么?
我正在建立一个视频网站,我希望我的用户能够从 Youtube 上传或嵌入视频.Youtube API 似乎不提供从他们的网站上传视频,是吗?所以我尝试通过 iframe
使用 PHP 嵌入视频.代码如下:
I'm building a video website and I want my users to be able to upload or embed videos from Youtube. The Youtube API doesn't seem to provide video upload from their website, or do they?
So I tried to embed videos via an iframe
with PHP. Here is the code:
<?php
$source=$_POST['source'];
?>
<html>
<div id="bo"><?php echo $source;?></div>
<form action="altupload.php" method="post">
<input type="text" name="source">
<input type="submit">
</form>
</html>
但我得到的是:
<html><div id="bo"><iframe width="560" height="315" src="http://www.youtube.com/embed/tZa5hyb0_wA" frameborder="0" allowfullscreen></iframe></div>`
<html>
<form action="altupload.php" method="post">
<input type="text" name="source">
<input type="submit">
</form>
</html>
谁能推荐一些其他的方法来做到这一点?谢谢
Can anyone recommend some other ways to do it? Thanks
推荐答案
允许用户仅上传来自 URL 的 youtube 视频 ID 为:
Allow the user upload only youtube video ID from URL as :
http://www.youtube.com/watch?v=Vw5FDZRGTL0
视频 ID:Vw5FDZRGTL0
你可以设置IFrame标签的其他选项:
and you can set other options of IFrame tag :
<iframe width="420" height="315" src="http://www.youtube.com/embed/<?php echo $videoID; ?>" frameborder="0" allowfullscreen></iframe>
祝你好运
相关文章