Professional Documents
Culture Documents
Mohammed Abdallah
Session Overview
Youtube (platform) Youtube API Examples
This presentation was made specially For this GTUG Event @2012
Youtube platform
Linux (suse) Apache Mysql Python Lighttpd
This presentation was made specially For this GTUG Event @2012
Video ID
Base 64
A-Z, a-z, 0-9, +, or / Padding 0, 1, 2 with = at the end Ex: eW91dHViZQ==
Youtube API
Player API
Front-end Javascript, ActionScript 3 Embedded, Chromeless
Player API
Embedded
AS2 (deprecated) AS3
Chromeless
Javascript ActionScript 3 No controls (HTML controls)
This presentation was made specially For this GTUG Event @2012
This presentation was made specially For this GTUG Event @2012
API Version
2 User has Youtube Account 2.1 User has not Youtube Account (using Google account) 1 Not valid request v parameter
This presentation was made specially For this GTUG Event @2012
Client Libraries
Java .NET PHP Python Objective-C
This presentation was made specially For this GTUG Event @2012
Feed Types
Video feed User's Playlists feed Video comments feed User's profile feed User's contacts feed User's subscriptions feed
This presentation was made specially For this GTUG Event @2012
Video feed
Videos feed Standard feeds Playlist feed
This presentation was made specially For this GTUG Event @2012
This presentation was made specially For this GTUG Event @2012
Searching
GET: http://gdata.youtube.com/feeds/api/videos
This presentation was made specially For this GTUG Event @2012
Searching parameters
duration:
short: less than 4 minutes medium: between 4 and 20 minutes long: longer than 20 minutes
Format:
1: RTSP streaming URL for mobile video playback. H.263 video 5: HTTP URL to the embeddable 6: RTSP streaming URL for mobile video playback. MPEG-4 SP video
This presentation was made specially For this GTUG Event @2012
Searching parameters
hd orderby:
relevance published viewCount rating
This presentation was made specially For this GTUG Event @2012
Searching (Example)
$yt = new Zend_Gdata_YouTube(); $query = $yt->newVideoQuery(); $query->setQuery($searchTerm); $query->setStartIndex($startIndex); $query->setMaxResults($maxResults); $feed = $yt->getVideoFeed($query);
This presentation was made specially For this GTUG Event @2012
Searching (Example)
foreach ($feed as $entry) { $videoId = $entry->getVideoId(); $thumbnailUrl = $entry->mediaGroup->thumbnail[0]->url; $videoTitle = $entry->mediaGroup->title; $videoDescription = $entry->mediaGroup->description; // print result }
This presentation was made specially For this GTUG Event @2012
Uploading
Browser-based uploading Direct upload
This presentation was made specially For this GTUG Event @2012
Authentication
AuthSub ClientLogin OAuth
This presentation was made specially For this GTUG Event @2012
Browser-based uploading
Upload video metadata API response (URL, Token) Upload the video file
This presentation was made specially For this GTUG Event @2012
Browser-based uploading
POST: gdata.youtube.com/action/GetUploadToken
authentication_token ClientLogin, AuthSub single-use, AuthSub session, OAuth developer_key content_length API_XML_Request
This presentation was made specially For this GTUG Event @2012
API_XML_REQUEST
<?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">Youtube API GTUG Gaza</media:title> <media:description type="plain"> Youtube API session </media:description> <media:category scheme="http://gdata.youtube.com/schemas/2007/categories.cat">People </media:category> <media:keywords>youtube, api</media:keywords> </media:group> </entry>
This presentation was made specially For this GTUG Event @2012
Soft cap!
Youtube accounts have soft cap of 2000 videos.
After first 2000, 50 additional videos/day
This presentation was made specially For this GTUG Event @2012
Direct Upload
POST: uploads.gdata.youtube.com/feeds/api/users/default/uploads
youtube_username (ClientLogin only) authentication_token developer_key video_filename boundary_string content_length API_XML_Request video_content_type Binary File Data (such as video/mp4 or application/octet-stream)
This presentation was made specially For this GTUG Event @2012
Links
Dashboard: https://code.google.com/apis/youtube/dashboard/gwt/ Create Channel: http://www.youtube.com/create_channel
This presentation was made specially For this GTUG Event @2012
https://developers.google.com/youtube/2.0/devel opers_guide_php
This presentation was made specially For this GTUG Event @2012
Thank you
This presentation was made specially For this GTUG Event @2012