What is the best way to embed Youtube videos?(嵌入 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>
祝你好运
这篇关于嵌入 Youtube 视频的最佳方式是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:嵌入 Youtube 视频的最佳方式是什么?
基础教程推荐
- 有什么方法可以用编码 UTF-8 而不是 Unicode 返回 PHP`json_encode`? 2021-01-01
- 如何在 Laravel 中使用 React Router? 2022-01-01
- 如何在 Laravel 5.3 注册中添加动态下拉列表列? 2021-01-01
- Cron Jobs 调用带有变量的 PHP 脚本 2022-01-01
- 学说 dbal querybuilder 作为准备好的语句 2022-01-01
- YouTube API v3 点赞视频,但计数器不增加 2022-01-01
- PHP 类:全局变量作为类中的属性 2021-01-01
- 在PHP中根据W3C规范Unicode 2022-01-01
- 如何替换eregi() 2022-01-01
- PHP PDO MySQL 查询 LIKE ->多个关键词 2021-01-01
