Skip to content
Branch: master
Find file History
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
..
Failed to load latest commit information.
tests
.gitignore
README.md Fix dotnet sample urls Jan 13, 2017
add_channel_section.php updates comments to use google/apiclient:^2.0 and adds tests, better … Jul 25, 2016
add_subscription.php updates comments to use google/apiclient:^2.0 and adds tests, better … Jul 25, 2016
captions.php
channel_localizations.php
channel_section_localizations.php
comment_handling.php
comment_threads.php
create_broadcast.php
create_reporting_job.php
geolocation_search.php
index.php
list_broadcasts.php
list_streams.php updates comments to use google/apiclient:^2.0 and adds tests, better … Jul 25, 2016
my_uploads.php
playlist_localizations.php
playlist_updates.php
quickstart.php
resumable_upload.php
retrieve_reports.php
search.php
shuffle_channel_sections.php
update_video.php
upload_banner.php
upload_thumbnail.php updates comments to use google/apiclient:^2.0 and adds tests, better … Jul 25, 2016
video_localizations.php updates comments to use google/apiclient:^2.0 and adds tests, better … Jul 25, 2016

README.md

Samples in this directory:

Add a channel section

Method: youtube.channelSections.insert
Description: This sample calls the API's channelSections.insert method to create channel sections. The code accepts a number of command line arguments that let you specify the section's type, display style, title, position, and content.

This sample also updates the channel's brandingSettings.channel.showBrowseView property so that the channel displays content in a browse view (rather than a feed view). A channel's sections are only visible if the channel displays content in a browse view.

More information on channel sections is available in the YouTube Help Center.

Add a channel subscription

Method: youtube.subscriptions.insert
Description: This sample calls the API's subscriptions.insert method to add a subscription to a specified channel.

Create a playlist

Method: youtube.playlists.insert
Description: This sample calls the API's playlists.insert method to create a private playlist owned by the channel authorizing the request.

Create and manage comments

Method: youtube.commentThreads.list, youtube.comments.insert, youtube.comments.list, youtube.comments.update, youtube.comments.setModerationStatus, youtube.comments.markAsSpam, youtube.comments.delete
Description: The following code sample demonstrates how to use the following API methods to create and manage comments:

  • It calls the commentThreads.list method with the videoId parameter set to retrieve comments for a video.
  • It calls the comments.insert method with the parentId parameter set to reply to an existing comment.
  • It calls the comments.list method with the parentId parameter to retrieve the comments in the thread.
  • It calls the comments.update method with comment in the request body to update a comment.
  • It calls the comments.setModerationStatus method to set the moderation status of the comment, the comments.markAsSpam method to mark the comment as spam, and the comments.delete method to delete the comment, using the id parameter to identify the comment.

Create and manage comment threads

Method: youtube.commentThreads.insert, youtube.commentThreads.list, youtube.commentThreads.update
Description: This sample demonstrates how to use the following API methods to create and manage top-level comments:

  • It calls the commentThreads.insert method once with the channelId parameter to create a channel comment and once with the videoId parameter to create a video comment.
  • It calls the commentThreads.list method once with the channelId parameter to retrieve channel comments and once with the videoId parameter to retrieve video comments.
  • It calls the commentThreads.update method once to update a video comment and then again to update a channel comment. In each case, the request body contains the comment resource being updated.

Create and manage YouTube video caption tracks

Method: youtube.captions.insert, youtube.captions.list, youtube.captions.update, youtube.captions.download, youtube.captions.delete
Description: This sample demonstrates how to use the following API methods to create and manage YouTube video caption tracks:

  • It calls the captions.insert method with the isDraft parameter set to true to upload a caption track in draft status.
  • It calls the captions.list method with the videoId parameter to retrieve video caption tracks.
  • It calls the captions.update method with the caption in the request body to update a caption track.
  • It calls the captions.download method to download the caption track.
  • It calls the captions.delete method to delete the caption track, using the id parameter to identify the caption track.

Retrieve my uploads

Method: youtube.playlistItems.list
Description: This sample calls the API's playlistItems.list method to retrieve a list of videos uploaded to the channel associated with the request. The code also calls the channels.list method with the mine parameter set to true to retrieve the playlist ID that identifies the channel's uploaded videos.

Search by keyword

Method: youtube.search.list
Description: This sample calls the API's search.list method to retrieve search results associated with a particular keyword.

Search by location

Method: youtube.search.list, youtube.videos.list
Description: This sample calls the API's search.list method with the type, q, location and locationRadius parameters to retrieve search results matching the provided keyword within the radius centered at a particular location. Using the video IDs from the search result, the sample calls the API's videos.list method to retrieve location details of each video.

Set and retrieve localized channel metadata

Method: youtube.channels.update, youtube.channels.list
Description: This sample demonstrates how to use the following API methods to set and retrieve localized metadata for a channel:

  • It calls the channels.update method to update the default language of a channel's metadata and to add a localized version of this metadata in a selected language. Note that to set the default language for a channel resource, you actually need to update the brandingSettings.channel.defaultLanguage property.
  • It calls the channels.list method with the hl parameter set to a specific language to retrieve localized metadata in that language.
  • It calls the channels.list method and includes localizations in the part parameter value to retrieve all of the localized metadata for that channel.

Set and retrieve localized channel section metadata

Method: youtube.channelSections.update, youtube.channelSections.list
Description: This sample demonstrates how to use the following API methods to set and retrieve localized metadata for a channel section:

  • It calls the channelSections.update method to update the default language of a channel section's metadata and to add a localized version of this metadata in a selected language.
  • It calls the channelSections.list method with the hl parameter set to a specific language to retrieve localized metadata in that language.
  • It calls the channelSections.list method and includes localizations in the part parameter value to retrieve all of the localized metadata for that channel section.

Set and retrieve localized playlist metadata

Method: youtube.playlists.update, youtube.playlists.list
Description: This sample demonstrates how to use the following API methods to set and retrieve localized metadata for a playlist:

  • It calls the playlists.update method to update the default language of a playlist's metadata and to add a localized version of this metadata in a selected language.
  • It calls the playlists.list method with the hl parameter set to a specific language to retrieve localized metadata in that language.
  • It calls the playlists.list method and includes localizations in the part parameter value to retrieve all of the localized metadata for that playlist.

Set and retrieve localized video metadata

Method: youtube.videos.update, youtube.videos.list
Description: This sample demonstrates how to use the following API methods to set and retrieve localized metadata for a video:

  • It calls the videos.update method to update the default language of a video's metadata and to add a localized version of this metadata in a selected language.
  • It calls the videos.list method with the hl parameter set to a specific language to retrieve localized metadata in that language.
  • It calls the videos.list method and includes localizations in the part parameter value to retrieve all of the localized metadata for that video.

Shuffle existing channel sections

Method: youtube.channelSections.list,youtube.channelSections.update
Description: This sample calls the API's channelSections.list method to get the list of current channel sections, shuffles them, and then calls channelSections.update to change the position of each.

More information on channel sections is available in the YouTube Help Center.

Update a video

Method: youtube.videos.update
Description: This code sample demonstrates how to add tags into an existing video.

The following code sample calls the API's youtube.videos.list method with id parameter set to videoId to get the video object. Using this video object, the sample gets the list of tags and appends new tags at the end of this list. Finally, the code calls youtube.videos.update method with updated video object to persist these changes on YouTube.

Upload a banner image and set as channel's banner

Method: youtube.channelBanners.insert, youtube.channels.update
Description: This sample calls the API's channelBanners.insert method to upload an image. With the returned URL, the sample calls channels.update method to update the channel's banner to this image.

Upload a custom video thumbnail image

Method: youtube.thumbnails.set
Description: This sample demonstrates how to upload a custom video thumbnail to YouTube and set it for a video. It calls the API's youtube.thumbnails.set method with videoId parameter set to a video ID to use a custom image as a thumbnail to the video. For the image upload, the program utilizes the Google_MediaFileUpload class with the resumable parameter set to true to upload the image piece-by-piece, allowing for subsequent retries to resume uploading from a point close to where the previous retry failed, a feature useful for programs that need to upload large files.

Upload a video

Method: youtube.videos.insert
Description: The following code sample calls the API's videos.insert method to add a video to user's channel. The code also utilizes Google_MediaFileUpload class with the resumable upload parameter set to true to be able to to upload the video in chunks.

Create a broadcast and stream

Method: youtube.liveBroadcasts.bind,youtube.liveBroadcasts.insert,youtube.liveStreams.insert
Description: This sample calls the API's liveBroadcasts.insert and liveStreams.insert methods to create a broadcast and a stream. Then, it calls the liveBroadcasts.bind method to bind the stream to the broadcast.

Retrieve a channel's broadcasts

Method: youtube.liveBroadcasts.list
Description: This sample calls the API's liveBroadcasts.list method to retrieve a list of broadcasts for the channel associated with the request. By default, the request retrieves all broadcasts for the channel, but you can also specify a value for the --broadcast-status option to only retrieve broadcasts with a particular status.

Retrieve a channel's live video streams

Method: youtube.liveStreams.list
Description: This sample calls the API's liveStreams.list method to retrieve a list of video stream settings that a channel can use to broadcast live events on YouTube.

Create a reporting job

Method: youtubeReporting.reportTypes.list, youtubeReporting.jobs.create
Description: This sample demonstrates how to create a reporting job. It calls the reportTypes.list method to retrieve a list of available report types. It then calls the jobs.create method to create a new reporting job.

Retrieve reports

Method: youtubeReporting.jobs.list, youtubeReporting.reports.list
Description: This sample demonstrates how to retrieve reports created by a specific job. It calls the jobs.list method to retrieve reporting jobs. It then calls the reports.list method with the jobId parameter set to a specific job id to retrieve reports created by that job. Finally, the sample prints out the download URL for each report.

You can’t perform that action at this time.