Search code examples
.netvb.netyoutube-apigdata-api

Setting a YouTube video's yt:AccessControl using VB.NET


How I can disable comments/rate in video using Visual Basic .NET ?

Basically, how can I set the yt:accessControl element?

How make this request in VB .NET https://code.google.com/intl/pl/apis/youtube/2.0/developers_guide_protocol_updating_and_deleting_videos.html#Updating_Video_Entry


Solution

  • You will have to update the information via an HTTP PUT, specifically, using the video's id.

    Here is an example of an HTTP PUT (taken from the second link above) which shows what the request to update a video would look like:

    PUT /feeds/api/users/USERNAME/uploads/VIDEO_ID HTTP/1.1
    Host: gdata.youtube.com
    Content-Type: application/atom+xml
    Content-Length: CONTENT_LENGTH
    Authorization: AuthSub token="AUTHORIZATION_TOKEN"
    GData-Version: 2
    X-GData-Key: key=DEVELOPER_KEY
    
    <?xml version="1.0"?>
    <entry xmlns="http://www.w3.org/2005/Atom"
        xmlns:media="http://search.yahoo.com/mrss/"
        xmlns:yt="http://gdata.youtube.com/schemas/2007">
        <media:group>
            <media:title type="plain">Yippee Skippy</media:title>
            <media:description type="plain">I am updating this 
                video.</media:description>
            <media:category 
                scheme="http://gdata.youtube.com/schemas/2007/categories.cat">
                People</media:category>
            <media:keywords>blastoff,rodeo,whiteboards</media:keywords>
        </media:group>
        <yt:accessControl action="comment" permission="allowed"/>
        <yt:accessControl action="commentVote" permission="allowed"/>
        <yt:accessControl action="videoRespond" permission="allowed"/>
        <yt:accessControl action="rate" permission="allowed"/>
        <yt:accessControl action="list" permission="allowed"/>
        <yt:accessControl action="embed" permission="allowed"/>
        <yt:accessControl action="syndicate" permission="allowed"/>
    </entry>
    

    Note the multiple yt:accessControl elements at the end indicating the permissions of the video being set.

    Also note that you can set these permissions when uploading the video as well.