代码之家  ›  专栏  ›  技术社区  ›  HyderA

直接上传Zend PHP:如何禁用上传视频的评论?

  •  0
  • HyderA  · 技术社区  · 15 年前

    下面是我的代码示例:

    $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();
    

    伙计们,可能只是一行代码。我找不到任何文件。

    2 回复  |  直到 15 年前
        1
  •  1
  •   Pekka    15 年前

    搜索 Zend_Gdata_YouTube_VideoEntry disable comments 出现 this

    我不确定最新的Zend客户端库版本是否添加了 本机支持 yt:accessControl 准备好了。你应该是 能够基于 语言中立文档:。。。。

        2
  •  2
  •   Pepper    15 年前

    这个主题已经有7个月的历史了,看起来Zend API仍然不支持yt:accessControl选项。不过,还是有办法的!看看吧,其实没那么糟,而且对我很有用。

    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); 
    
    推荐文章