因此,我可以使用PHP客户端库将视频上传到YouTube (直接上传),并将其设置为私有,但是否可以将其设置为未列出?
发布于 2012-11-16 19:51:19
您必须将此代码用作请求的XML元素的子元素:
<yt:accessControl action="list" permission="denied"/>
如果您不能手动添加它(通常使用zend),您可以使用以下代码添加相应的zend条目:
//Creates an extension to Zend Framework
$element = new Zend_Gdata_App_Extension_Element('yt:accessControl', 'yt', 'http://gdata.youtube.com/schemas/2007', '');
//Adds the corresponding XML child/attribute
$element->extensionAttributes = array(array('namespaceUri' => '', 'name' => 'action', 'value' => 'list'), array('namespaceUri' => '', 'name' => 'permission', 'value' => 'denied'));
//Adds this extension to you video entry where "$myVideo" is your video to be uploaded
$myVideo->extensionElements = array($element);
希望这能有所帮助:D
发布于 2014-01-23 18:40:12
这样做..。使用API版本2和ZEND GDATA。如果您查看$videoEntry的内容,您会注意到$_extensionElements和$_extensionArributes。因此,从数组的扩展类向后看,您会发现抽象类Zend_Gdata_App_Base,它有一个函数setExtensionElements( VideoEntry )。因此,只要按照别人说的那样创建accesControlElement并将其传递给该函数即可。而且很管用。
$videoEntry = $yt->getFullVideoEntry($id);
if ($videoEntry->getEditLink() !== null) {
echo "<b>Video is editable by current user</b><br />";
$putUrl = $videoEntry->getEditLink()->getHref();
//set video to unlisted
$accessControlElement = new Zend_Gdata_App_Extension_Element(
'yt:accessControl', 'yt', 'http://gdata.youtube.com/schemas/2007', ''
);
$accessControlElement->extensionAttributes = array(
array(
'namespaceUri' => '',
'name' => 'action',
'value' => 'list'
),
array(
'namespaceUri' => '',
'name' => 'permission',
'value' => 'denied'
));
// here is the hidden function
// it´s on a abstract class Zend/Gdata/App/Base/Base.php
// Where ZEND/Gdata/Youtube/VideoEntry.php extends
$videoEntry->setExtensionElements(array($accessControlElement));
$yt->updateEntry($videoEntry, $putUrl);
}else{
echo "<b>EL Video no es editable por este usuario</b><br />";
}
https://stackoverflow.com/questions/6255807
复制相似问题