开发者

Direct Upload Zend PHP: How do I disable comments on videos being uploaded?

开发者 https://www.devze.com 2023-01-22 10:50 出处:网络
Here\'s a sample of my code: $httpClient = Zend_Gdata_ClientLogin::getHttpClient( $username, $password, $service, $client, $source, $loginToken, $loginCaptcha, $authenticationURL);

Here's a sample of my code:

$httpClient = Zend_Gdata_ClientLogin::getHttpClient( $username, $password, $service, $client, $source, $loginToken, $loginCaptcha, $authenticationURL);
$httpClient->setHeaders('X-GData-Key', "key=${myDeveloperKey}");

$yt = new Zend_Gdata_YouTube($httpClient);

$myVideoEntry = new Zend_Gdata_YouTube_VideoEntry();

$filesource = $yt->newMediaFileSource($filename);
$filesource->setContentType('video/quicktime');
$filesource->setSlug($filename);

$myVideoEntry->setMediaSource($filesource);

$mediaGroup = $yt->newMediaGroup();
$mediaGroup->title = $yt->newMediaTitle()->setText(POST("title"));
$mediaGroup->开发者_运维问答description = $yt->newMediaDescription()->setText(POST("description"));
$mediaGroup->category = array(
    $yt->newMediaCategory()->setText(POST("category"))->setScheme('http://gdata.youtube.com/schemas/2007/categories.cat'),
    $yt->newMediaCategory()->setText('mydevelopertag')->setScheme('http://gdata.youtube.com/schemas/2007/developertags.cat')
);
$mediaGroup->keywords = $yt->newMediaKeywords()->setText(POST("tags"));

$myVideoEntry->mediaGroup = $mediaGroup;
$uploadUrl = 'http://uploads.gdata.youtube.com/feeds/users/default/uploads';
$newEntry = $yt->insertEntry($myVideoEntry, $uploadUrl, 'Zend_Gdata_YouTube_VideoEntry');

$youtube_id = $newEntry->getVideoID();

Please note that this is just a sample of the code for simplicity. The full code is much more complex and is tested to work.

C'mon guys, it's probably just a single line of code. I couldn't find any documentation on it.


This topic is 7 months old and it looks like the Zend API still doesnt support the yt:accessControl options out of the box. There is a solution though! Check it out, its not that bad actually and it works for me.

http://gdatatips.blogspot.com/2008/12/creating-extension-elements-in-php.html http://groups.google.com/group/youtube-api-gdata/msg/2346e9c0a2cb223d/

$newVideoEntry = new Zend_Gdata_YouTube_VideoEntry();
$newVideoEntry->setVideoTitle( 'test title' );
$newVideoEntry->setVideoDescription( 'test description' );
$newVideoEntry->setVideoCategory( 'Music' );

$accessControlElement = new Zend_Gdata_App_Extension_Element('yt:accessControl', 'yt', 'http://gdata.youtube.com/schemas/2007', ''); 
$accessControlElement->extensionAttributes = array(array('namespaceUri' => '', 'name' => 'action', 'value' => 'comment'), array('namespaceUri' => '', 'name' => 'permission', 'value' => 'denied')); 
$newVideoEntry->extensionElements = array($accessControlElement); 


Googling for Zend_Gdata_YouTube_VideoEntry disable comments turns up this:

I'm not sure that the latest Zend client library release has added native support for the yt:accessControl setting yet. You should be able to manually construct the relevant Atom XML element based on the language-neutral documentation: ....

it looks like you'd have to change the raw data being sent. I don't know how difficult that is. Maybe it helps anyway.

0

精彩评论

暂无评论...
验证码 换一张
取 消