我正在做这个网站,用户使用youtube链接注册并上传视频。我不想使用Youtube频道。我是 php 编程的新手,我不知道如何做到这一点。用户上传视频后,该页面还必须具有网站上视频的类别列表。
任何帮助将不胜感激
编辑:这是我到目前为止得到的,我不知道我是如何到达这里的,我只知道它不起作用。它有一个模式,允许用户输入视频链接并将其导入将显示所有视频的页面。
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>test 1</title>
<link rel="stylesheet" href="assets/css/bootstrap.min.css">
<link rel="stylesheet" href="assets/css/bootstrap-theme.min.css">
<link rel="stylesheet" href="assets/css/font-awesome.min.css">
<link rel="stylesheet" href="assets/css/style.css">
<script src="assets/js/jquery.min.js"></script>
<script src="assets/js/bootstrap.min.js"></script>
</head>
<body>
<div class="col-md-8">
<div class="video-embed-iframe">
<div class="embed-responsive embed-responsive-16by9">
<iframe src="http://www.youtube.com/embed/{$videos_youtube_id}?autoplay={$player_autoplay}&showinfo={$player_showinfo}&rel={$player_related}&controls={$player_controls}&loop={$player_loop}&color={$player_color}" allowfullscreen></iframe>
</div>
</div>
<div class="modal fade" id="upload-modal">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title"><span class="fa fa-upload"></span> {$lang_upload_new_videos}</h4>
</div>
<div class="modal-body">
<div id="upload-message"></div>
<form id="upload-form" method="POST" action="">
<div class="row">
<div class="col-md-12">
<div class="form-group">
<label for="category">{$lang_category} <span>*</span> </label>
<select class="form-control" name="category" id="category">
{section name=x loop=$categories}
<option value="{$categories[x].id}">{$categories[x].category}</option>
{/section}
</select>
</div>
<div class="form-group">
<label for="link">{$lang_videos_link} <span>*</span> </label>
<input type="text" class="form-control" name="link" dir="ltr" id="link" placeholder="https://www.youtube.com/watch?v=uJcB3ZaaLlA" />
<p class="help-block" dir="ltr">youtube video link</p>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" id="import_btn" class="btn btn-inverse pull-left">{$lang_import}</button>
</div>
</form>
</div>
</div>
</div>
</body>
</html>
既然你说你也是PHP的新手,我建议你在这个问题上多研究一下。
但这是一个工作代码,希望对您有所帮助。
if($client->getAccessToken()) {
$snippet = new Google_VideoSnippet();
$snippet->setTitle("Test title");
$snippet->setDescription("Test descrition");
$snippet->setTags(array("tag1","tag2"));
$snippet->setCategoryId("22");
$status = new Google_VideoStatus();
$status->privacyStatus = "private";
$video = new Google_Video();
$video->setSnippet($snippet);
$video->setStatus($status);
$error = true;
$i = 0;
try {
$obj = $youTubeService->videos->insert("status,snippet", $video,
array("data"=>file_get_contents("video.mp4"),
"mimeType" => "video/mp4"));
} catch(Google_ServiceException $e) {
print "Caught Google service Exception ".$e->getCode(). " message is ".$e->getMessage(). " <br>";
print "Stack trace is ".$e->getTraceAsString();
}
}