|
| 1 | +## Samples in this directory: |
| 2 | + |
| 3 | +### [Add a channel section](/youtube/api-samples/blob/master/php/add_channel_section.php) |
| 4 | + |
| 5 | +Method: youtube.channelSections.insert<br> |
| 6 | +Description: This sample calls the API's <code>channelSections.insert</code> method to create channel sections. |
| 7 | +The code accepts a number of command line arguments that let you specify the section's type, display style, title, position, |
| 8 | +and content.<br><br> |
| 9 | +This sample also updates the channel's |
| 10 | +<code><a href="/youtube/v3/docs/channels#brandingSettings.channel.showBrowseView">brandingSettings.channel.showBrowseView</a></code> |
| 11 | +property so that the channel displays content in a browse view (rather than a feed view). A channel's sections are only |
| 12 | +visible if the channel displays content in a browse view.</p><p>More information on channel sections is available in the |
| 13 | +<a href="https://support.google.com/youtube/answer/3027787">YouTube Help Center</a>. |
| 14 | + |
| 15 | +### [Add a channel subscription](/youtube/api-samples/blob/master/php/add_subscription.php) |
| 16 | + |
| 17 | +Method: youtube.subscriptions.insert<br> |
| 18 | +Description: This sample calls the API's <code>subscriptions.insert</code> method to add a subscription to a specified |
| 19 | +channel. |
| 20 | + |
| 21 | +### [Create and manage YouTube video caption tracks](/youtube/api-samples/blob/master/php/captions.php) |
| 22 | + |
| 23 | +Method: youtube.captions.insert, youtube.captions.list, youtube.captions.update, youtube.captions.download, |
| 24 | +youtube.captions.delete<br> |
| 25 | +Description: This sample demonstrates how to use the following API methods to create and manage YouTube video caption |
| 26 | +tracks:<br> |
| 27 | +<ul> |
| 28 | +<li>It calls the <code>captions.insert</code> method with the <code>isDraft</code> parameter set to <code>true</code> |
| 29 | +to upload a caption track in draft status.</li> |
| 30 | +<li>It calls the <code>captions.list</code> method with the <code>videoId</code> parameter to retrieve video caption |
| 31 | +tracks.</li> |
| 32 | +<li>It calls the <code>captions.update</code> method with the caption in the request body to update a caption track.</li> |
| 33 | +<li>It calls the <code>captions.download</code> method to download the caption track.</li> |
| 34 | +<li>It calls the <code>captions.delete</code> method to delete the caption track, using the <code>id</code> parameter to |
| 35 | +identify the caption track.</li> |
| 36 | +</ul> |
| 37 | + |
| 38 | +### [Set and retrieve localized metadata for a channel](/youtube/api-samples/blob/master/php/channel_localizations.php) |
| 39 | + |
| 40 | +Method: youtube.channels.update, youtube.channels.list<br> |
| 41 | +Description: This sample demonstrates how to use the following API methods to set and retrieve localized metadata for a |
| 42 | +channel:<br> |
| 43 | +<ul> |
| 44 | +<li>It calls the <code>channels.update</code> method to update the default language of a channel's metadata and to add a |
| 45 | +localized version of this metadata in a selected language. Note that to set the default language for a channel resource, |
| 46 | +you actually need to update the <code>brandingSettings.channel.defaultLanguage</code> property.</li> |
| 47 | +<li>It calls the <code>channels.list</code> method with the <code>hl</code> parameter set to a specific language to |
| 48 | +retrieve localized metadata in that language.</li> |
| 49 | +<li>It calls the <code>channels.list</code> method and includes <code>localizations</code> in the <code>part</code> |
| 50 | +parameter value to retrieve all of the localized metadata for that channel.</li> |
| 51 | +</ul> |
| 52 | + |
| 53 | +### [Set and retrieve localized metadata for a channel section](/youtube/api-samples/blob/master/php/channel_section_localizations.php) |
| 54 | + |
| 55 | +Method: youtube.channelSections.update, youtube.channelSections.list<br> |
| 56 | +Description: This sample demonstrates how to use the following API methods to set and retrieve localized metadata for a |
| 57 | +channel section:<br> |
| 58 | +<ul> |
| 59 | +<li>It calls the <code>channelSections.update</code> method to update the default language of a channel section's |
| 60 | +metadata and to add a localized version of this metadata in a selected language.</li> |
| 61 | +<li>It calls the <code>channelSections.list</code> method with the <code>hl</code> parameter set to a specific language |
| 62 | +to retrieve localized metadata in that language.</li> |
| 63 | +<li>It calls the <code>channelSections.list</code> method and includes <code>localizations</code> in the |
| 64 | +<code>part</code> parameter value to retrieve all of the localized metadata for that channel section.</li> |
| 65 | +</ul> |
| 66 | + |
| 67 | +### [Create and manage comments](/youtube/api-samples/blob/master/php/comment_handling.php) |
| 68 | + |
| 69 | +Method: youtube.commentThreads.list, youtube.comments.insert, youtube.comments.list, youtube.comments.update, |
| 70 | +youtube.comments.setModerationStatus, youtube.comments.markAsSpam, youtube.comments.delete<br> |
| 71 | +Description: The following code sample demonstrates how to use the following API methods to create and manage comments:<br> |
| 72 | +<ul> |
| 73 | +<li>It calls the <code>commentThreads.list</code> method with the <code>videoId</code> parameter set to retrieve comments |
| 74 | +for a video.</li> |
| 75 | +<li>It calls the <code>comments.insert</code> method with the <code>parentId</code> parameter set to reply to an existing |
| 76 | +comment.</li> |
| 77 | +<li>It calls the <code>comments.list</code> method with the <code>parentId</code> parameter to retrieve the comments in the |
| 78 | +thread.</li> |
| 79 | +<li>It calls the <code>comments.update</code> method with comment in the request body to update a comment.</li> |
| 80 | +<li>It calls the <code>comments.setModerationStatus</code> method to set the moderation status of the comment, the |
| 81 | +<code>comments.markAsSpam</code> method to mark the comment as spam, and the <code>comments.delete</code> method to |
| 82 | +delete the comment, using the <code>id</code> parameter to identify the comment.</li> |
| 83 | +</ul> |
| 84 | + |
| 85 | +### [Create and manage comment threads](/youtube/api-samples/blob/master/php/comment_threads.php) |
| 86 | + |
| 87 | +Method: youtube.commentThreads.insert, youtube.commentThreads.list, youtube.commentThreads.update<br> |
| 88 | +Description: This sample demonstrates how to use the following API methods to create and manage top-level comments:<br> |
| 89 | +<ul> |
| 90 | +<li>It calls the <code>commentThreads.insert</code> method once with the <code>channelId</code> parameter to create a |
| 91 | +channel comment and once with the <code>videoId</code> parameter to create a video comment.</li> |
| 92 | +<li>It calls the <code>commentThreads.list</code> method once with the <code>channelId</code> parameter to retrieve |
| 93 | +channel comments and once with the <code>videoId</code> parameter to retrieve video comments.</li> |
| 94 | +<li>It calls the <code>commentThreads.update</code> method once to update a video comment and then again to update a |
| 95 | +channel comment. In each case, the request body contains the <code>comment</code> resource being updated.</li> |
| 96 | +</ul> |
| 97 | + |
| 98 | +### [Create a broadcast](/youtube/api-samples/blob/master/php/create_broadcast.php) |
| 99 | + |
| 100 | +Method: youtube.liveBroadcasts.bind,youtube.liveBroadcasts.insert,youtube.liveStreams.insert<br> |
| 101 | +Description: This sample calls the API's <code>liveBroadcasts.insert</code> method to create a broadcast. |
| 102 | + |
| 103 | +### [Create a reporting job](/youtube/api-samples/blob/master/php/create_reporting_job.php) |
| 104 | + |
| 105 | +Method: youtubeReporting.reportTypes.list, youtubeReporting.jobs.create<br> |
| 106 | +Description: This sample demonstrates how to create a reporting job. It calls the <code>reportTypes.list</code> method |
| 107 | +to retrieve a list of available report types. It then calls the <code>jobs.create</code> method to create a new reporting |
| 108 | +job. |
| 109 | + |
| 110 | +### [Search by geolocation](/youtube/api-samples/blob/master/php/geolocation_search.php) |
| 111 | + |
| 112 | +Method: youtube.search.list, youtube.videos.list<br> |
| 113 | +Description: This sample calls the API's <code>search.list</code> method with <code>q</code>, <code>location</code> and |
| 114 | +<code>locationRadius</code> parameters to retrieve search results matching the provided keyword within the radius centered |
| 115 | +at a particular location. Using the video IDs from the search result, the sample calls the API's <code>videos.list</code> |
| 116 | +method to retrieve location details of each video. |
| 117 | + |
| 118 | +### [Retrieve a channel's broadcasts](/youtube/api-samples/blob/master/php/list_broadcasts.php) |
| 119 | + |
| 120 | +Method: youtube.liveBroadcasts.list<br> |
| 121 | +Description: This sample calls the API's <code>liveBroadcasts.list</code> method to retrieve a list of broadcasts for |
| 122 | +the channel associated with the request. By default, the request retrieves all broadcasts for the channel, but you can |
| 123 | +also specify a value for the <code>--broadcast-status</code> option to only retrieve broadcasts with a particular status. |
| 124 | + |
| 125 | +### [Retrieve a channel's live video streams](/youtube/api-samples/blob/master/php/list_streams.php) |
| 126 | + |
| 127 | +Method: youtube.liveStreams.list<br> |
| 128 | +Description: This sample calls the API's <code>liveStreams.list</code> method to retrieve a list of video stream settings |
| 129 | +that a channel can use to broadcast live events on YouTube. |
| 130 | + |
| 131 | +### [Retrieve my uploads](/youtube/api-samples/blob/master/php/my_uploads.php) |
| 132 | + |
| 133 | +Method: youtube.playlistItems.list<br> |
| 134 | +Description: This sample calls the API's <code>playlistItems.list</code> method to retrieve a list of videos uploaded |
| 135 | +to the channel associated with the request. The code also calls the <code>channels.list</code> method with the |
| 136 | +<code>mine</code> parameter set to <code>true</code> to retrieve the playlist ID that identifies the channel's uploaded |
| 137 | +videos. |
| 138 | + |
| 139 | +### [Set and retrieve localized metadata for a playlist](/youtube/api-samples/blob/master/php/playlist_localizations.php) |
| 140 | + |
| 141 | +Method: youtube.playlists.update, youtube.playlists.list<br> |
| 142 | +Description: This sample demonstrates how to use the following API methods to set and retrieve localized metadata for a |
| 143 | +playlist:<br> |
| 144 | +<ul> |
| 145 | +<li>It calls the <code>playlists.update</code> method to update the default language of a playlist's metadata and to add |
| 146 | +a localized version of this metadata in a selected language.</li> |
| 147 | +<li>It calls the <code>playlists.list</code> method with the <code>hl</code> parameter set to a specific language to |
| 148 | +retrieve localized metadata in that language.</li> |
| 149 | +<li>It calls the <code>playlists.list</code> method and includes <code>localizations</code> in the <code>part</code> |
| 150 | +parameter value to retrieve all of the localized metadata for that playlist.</li> |
| 151 | +</ul> |
| 152 | + |
| 153 | +### [Create a playlist](/youtube/api-samples/blob/master/php/playlist_updates.php) |
| 154 | + |
| 155 | +Method: youtube.playlists.insert<br> |
| 156 | +Description: This sample calls the API's <code>playlists.insert</code> method to create a private playlist owned by the |
| 157 | +channel authorizing the request. |
| 158 | + |
| 159 | +### [Upload a video](/youtube/api-samples/blob/master/php/resumable_upload.php) |
| 160 | + |
| 161 | +Method: youtube.videos.insert<br> |
| 162 | +Description: The following code sample calls the API's <code>videos.insert</code> method to add a video to user's |
| 163 | +channel. The code also utilizes <code>Google_MediaFileUpload</code> class with the <code>resumable upload</code> |
| 164 | +parameter set to <code>true</code> to be able to to upload the video in chunks. |
| 165 | + |
| 166 | +### [Retrieve reports](/youtube/api-samples/blob/master/php/retrieve_reports.php) |
| 167 | + |
| 168 | +Method: youtubeReporting.jobs.list, youtubeReporting.reports.list<br> |
| 169 | +Description: This sample demonstrates how to retrieve reports created by a specific job. It calls the |
| 170 | +<code>jobs.list</code> method to retrieve reporting jobs. It then calls the <code>reports.list</code> method with the |
| 171 | +<code>jobId</code> parameter set to a specific job id to retrieve reports created by that job. Finally, the sample |
| 172 | +prints out the download URL for each report. |
| 173 | + |
| 174 | +### [Search by keyword](/youtube/api-samples/blob/master/php/search.php) |
| 175 | + |
| 176 | +Method: youtube.search.list<br> |
| 177 | +Description: This sample calls the API's <code>search.list</code> method to retrieve search results associated with |
| 178 | +a particular keyword. |
| 179 | + |
| 180 | +### [Shuffle existing channel sections](/youtube/api-samples/blob/master/php/shuffle_channel_sections.php) |
| 181 | + |
| 182 | +Method: youtube.channelSections.list,youtube.channelSections.update<br> |
| 183 | +Description: This sample calls the API's <code>channelSections.list</code> method to get the list of current channel |
| 184 | +sections, shuffles them, and then calls <code>channelSections.update</code> to change the position of each.<br><br> |
| 185 | +More information on channel sections is available in the |
| 186 | +<a href="https://support.google.com/youtube/answer/3027787">YouTube Help Center</a>. |
| 187 | + |
| 188 | +### [Update a video](/youtube/api-samples/blob/master/php/update_video.php) |
| 189 | + |
| 190 | +Method: youtube.videos.update<br> |
| 191 | +Description: This code sample demonstrates how to add tags into an existing video.<br><br>The following code |
| 192 | +sample calls the API's <code>youtube.videos.list</code> method with <code>id</code> parameter set to videoId |
| 193 | +to get the video object. Using this video object, the sample gets the list of tags and appends new tags at the |
| 194 | +end of this list. Finally, the code calls <code>youtube.videos.update</code> method with updated video object |
| 195 | +to persist these changes on YouTube. |
| 196 | + |
| 197 | +### [Upload a banner image and set as channel's banner](/youtube/api-samples/blob/master/php/upload_banner.php) |
| 198 | + |
| 199 | +Method: youtube.channelBanners.insert, youtube.channels.update<br> |
| 200 | +Description: This sample calls the API's <code>channelBanners.insert</code> method to upload an image. With the |
| 201 | +returned URL, the sample calls <code>channels.update</code> method to update channel's banner to this image. |
| 202 | + |
| 203 | +### [Upload a video thumbnail image](/youtube/api-samples/blob/master/php/upload_thumbnail.php) |
| 204 | + |
| 205 | +Method: youtube.thumbnails.set<br> |
| 206 | +Description: This sample demonstrates how to upload a custom video thumbnail to YouTube and set it for a video. |
| 207 | +It calls the API's <code>youtube.thumbnails.set</code> method with <code>videoId</code> parameter set to a video |
| 208 | +ID to use a custom image as a thumbnail to the video. For the image upload, the program utilizes the |
| 209 | +<code>Google_MediaFileUpload</code> class with the <code>resumable</code> parameter set to |
| 210 | +<code>true</code> to upload the image piece-by-piece, allowing for subsequent retries to resume uploading from |
| 211 | +a point close to where the previous retry failed, a feature useful for programs that need to upload large files. |
| 212 | + |
| 213 | +### [Set and retrieve localized metadata for a video](/youtube/api-samples/blob/master/php/video_localizations.php) |
| 214 | + |
| 215 | +Method: youtube.videos.update, youtube.videos.list<br> |
| 216 | +Description: This sample demonstrates how to use the following API methods to set and retrieve localized metadata |
| 217 | +for a video:<br> |
| 218 | +<ul> |
| 219 | +<li>It calls the <code>videos.update</code> method to update the default language of a video's metadata and to add |
| 220 | +a localized version of this metadata in a selected language.</li> |
| 221 | +<li>It calls the <code>videos.list</code> method with the <code>hl</code> parameter set to a specific language to |
| 222 | +retrieve localized metadata in that language.</li> |
| 223 | +<li>It calls the <code>videos.list</code> method and includes <code>localizations</code> in the <code>part</code> |
| 224 | +parameter value to retrieve all of the localized metadata for that video.</li> |
| 225 | +</ul> |
0 commit comments