YouTube API with Java step-by-step

Reviews
Shared by: amberp
Stats
views:
572
rating:
not rated
reviews:
0
posted:
11/6/2008
language:
pages:
0
YouTube API with Java step-by-step 08. 05. 18 PM 10:55 @Edited by Lee Dong-Kyun Youtube OpenAPI with Java step-by-step [http://code.google.com/apis/youtube/developers_guide_java.html] . (Contact ) API [http://code.google.com/apis/youtube/reference.html] . Audience Google Data APIs Atom1.0 RSS2.0 API References . [http://code.google.com/apis/gdata/javadoc/] . Getting started . 1.5 , [http://code.google.com/p/gdata-java-client/downloads/list] Using a developer key and client ID API Developer key . key . [http://code.google.com/apis/youtube/dashboard/] Authentication Youtube API Google Developer's key AuthSub : AuthSub ClientLogin : ClientLogin . * Note : . Scheme 2 AuthSub ClientLogin . . . API AuthSub . , standalone ClientLogin , . The Authentication Process 1. 2. 3. 4. 5. 6. When the web application needs to access a user's Google service, it makes an AuthSub call to Google's Authentication Proxy service. The Authentication service responds by serving up an Access Request page. This Google-managed page prompts the user to grant/deny access to their Google service. The user may first be asked to log into their account. The user decides whether to grant or deny access to the web application. If the user denies access, they are directed to a Google page rather than back to the web application. If the user grants access, the Authentication service redirects the user back to the web application. The redirect contains an authentication token good for one use; it can be exchanged for a long-lived token. The web application contacts the Google service with a request, using the authentication token to act as an agent for the user. If the Google service recognizes the token, it supplies the requested data. API YouTubeService service = new YouTubeService1 YouTubeService clientID developer key . AuthSub for web applications AuthSub authentication 1. 2. 3. 4. 5. 6. 7. The user clicks a link on your site to upload a video. Your site redirects the user to YouTube's Authentication Proxy service. The user's browser sends a request to the authentication service. YouTube displays an Access Consent page, prompting the user to log in to his YouTube account. The user logs in to his account, and YouTube then asks the user to grant or deny the ability for your site to upload the user's video details. If the user grants access, YouTube redirects the user back to your site. The redirect URL contains the authentication token for your Upload API request. The user's browser sends a request, including the authentication token, to your site. The Google AuthSub documentation explains the optional step of exchanging the single-use authentication token for a session token that does not expire. AuthSub token AuthSubRequest URL . : the "next" URL . AuthSubRequest URL getRequestUrl String requestUrl = AuthSubUtil.getRequestUrl("http://www.example.com/RetrieveToken", "http://gdata.youtube.com", false, true); "next" URL AuthSubRequest URL AuthSubRequest Handler . . String suggestAuthorization = "

MyApp needs access to your YouTube account. To authorize MyApp to access your account, log into your account.

"; 1/9 YouTube API with Java step-by-step 08. 05. 18 PM 10:55 AuthSub System "next"URL http://www.example.com/RetrieveToken?token=DQAADKEDE. URL , getTokenFromReply exchangeForSessionToken 1 . getTokenFromReply . not registered mode null token set URL AuthSubSessionToken URL registered mode . URL . . String onetimeUseToken = AuthSubUtil.getTokenFromReply(httpServletRequest.getQueryString()); . (a private key) . setAuthSubToken . String sessionToken = AuthSubUtil.exchangeForSessionToken(onetimeUseToken, null); Authorization header . Authorization header null private key YouTubeService . . . . . . registered mode setAuthSubToken YouTubeService service = new YouTubeService(clientID, developer_key); service.setAuthSubToken(sessionToken, null); setAuthSubToken , GData . name-value . , getTokenInfo (expire) . , AuthSubRevokeToken revokeToken AuthSubUtil.revokeToken(sessionToken, null); Map info = AuthSubUtil.getTokenInfo(sessionToken, null); registered mode private key ClientLogin for installed applications ClientLogin authentication The image shows the following steps: 1. The user clicks a link on your site to upload a video. 2. Your application presents a form for the user to enter a YouTube username and password. 3. The user submits his YouTube username and password to your installed application. 4. Your application sends a ClientLogin authentication request to YouTube to obtain an authentication token for uploading the video. The request specifies the username and password for the user's YouTube user account, which will be the account associated with the video. 5. YouTube verifies the user's username and password and returns the authentication token to your application. If you are using browser-based uploading, the token will allow you to upload the video metadata. If you are using direct uploading, the token will allow you to upload the metadata and the actual video file. ClientLogin setUserCredentials . ID password . YouTubeService service = new YouTubeService(clientID, developer_key); service.setUserCredentials("jo@gmail.com", "password"); Tokens and Token Management . . . . . (expire) . Registration AuthSub -Unregistered : -Registered : -Registered with enhanced security : . . . (secure token) Understanding video feeds and entries API standards feeds, uploads, subscriptions, favorites feeds . Displaying a feed of videos Youtube API feeds video feeds , , VideoFeed . . . VideoEntry . URL VideoFeed videoFeed = service.getFeed(new URL(feedUrl), VideoFeed.class); for(VideoEntry entry : videoFeed.getEntries() ) { System.out.println("Title: " + entry.getTitle().getPlainText()); System.out.println(entry.getMediaGroup().getDescription().getPlainTextContent()); } Retrieving a specific video entry videoID Atom link id . . http://gdata.youtube.com/feeds/api/videos/videoID VideoEntry . String videoEntryUrl = "http://gdata.youtube.com/feeds/api/videos/ADos_xW4_J0"; VideoEntry videoEntry = service.getEntry(new URL(videoEntryUrl), VideoEntry.class); System.out.println("Title: " + videoEntry.getTitle().getPlainText()); System.out.println(videoEntry.getMediaGroup().getDescription().getPlainTextContent()); Video entry contents VideoEntry thumbnails, players URLs, video duration . . XML elements reference guide . 2/9 YouTube API with Java step-by-step 08. 05. 18 PM 10:55 System.out.println("Title: " + videoEntry.getTitle().getPlainText()); System.out.println("Uploaded by: " + videoEntry.getAuthors().get(0).getName()); YouTubeMediaGroup mediaGroup = videoEntry.getMediaGroup(); System.out.println("Description: " + mediaGroup.getDescription().getPlainTextContent()); MediaPlayer mediaPlayer = mediaGroup.getPlayer(); System.out.println("Web Player URL: " + mediaPlayer.getUrl()); MediaKeywords keywords = mediaGroup.getKeywords(); System.out.print("Keywords: "); for(String keyword : keywords.getKeywords()) { System.out.print(keyword + ","); } GeoRssWhere location = videoEntry.getGeoCoordinates(); if(location != null) { System.out.println("Latitude: " + location.getLatitude()); System.out.println("Longitude: " + location.getLongitude()); } Rating rating = videoEntry.getRating(); if(rating != null) { System.out.println("Average rating: " + rating.getAverage()); } YtStatistics stats = videoEntry.getStatistics(); if(stats != null ) { System.out.println("View count: " + stats.getViewCount()); } System.out.println(); System.out.println("\tThumbnails:"); for(MediaThumbnail mediaThumbnail : mediaGroup.getThumbnails()) { System.out.println("\t\tThumbnail URL: " + mediaThumbnail.getUrl()); System.out.println("\t\tThumbnail Time Index: " + mediaThumbnail.getTime()); System.out.println(); } System.out.println("\tMedia:"); for(YouTubeMediaContent mediaContent : mediaGroup.getYouTubeContents()) { System.out.println("\t\tMedia Location: "+ mediaContent.getUrl()); System.out.println("\t\tMedia Type: "+ mediaContent.getType()); System.out.println("\t\tDuration: " + mediaContent.getDuration()); System.out.println(); } Retrieving and searching for videos Retrieving standard feeds feeds URL http://gdata.youtube.com/feeds/api/standardfeeds/ Feed Name Most Viewed Top Rated Recently Featured Watch On Mobile Most Discussed Top Favorites Most Linked Most Responded Most Recent Feed Identifier most_viewed top_rated recently_featured watch_on_mobile most_discussed top_favorites most_linked most_responded most_recent locaeID http://gdata.youtube.com/feeds/api/standardfeeds/localeID/feedID. http://gdata.youtube.com/feeds/api/standardfeeds/JP/most_viewed. . String feedUrl = "http://gdata.youtube.com/feeds/api/standardfeeds/most_viewed"; VideoFeed videoFeed = service.getFeed(new URL(feedUrl), VideoFeed.class); for(VideoEntry entry : videoFeed.getEntries() ) { System.out.println("Title: " + entry.getTitle().getPlainText()); System.out.println(entry.getMediaGroup().getDescription().getPlainTextContent()); } Videos uploaded by a specific user /feeds/api/users/userID/uploads "G String feedUrl = "http://gdata.youtube.com/feeds/api/users/GoogleDevelopers/uploads"; VideoFeed videoFeed = service.getFeed(new URL(feedUrl), VideoFeed.class); for(VideoEntry entry : videoFeed.getEntries() ) { System.out.println("Title: " + entry.getTitle().getPlainText()); System.out.println(entry.getMediaGroup().getDescription().getPlainTextContent()); } "default" . http://gdata.youtube.com/feeds/api/users/default/uploads. Retrieving related videos related video .( . ) if (videoEntry.getRelatedVideosLink() != null) { String feedUrl = videoEntry.getRelatedVideosLink().getHref(); VideoFeed videoFeed = service.getFeed(new URL(feedUrl), VideoFeed.class); for(VideoEntry entry : videoFeed.getEntries() ) { System.out.println("Title: " + entry.getTitle().getPlainText()); System.out.println(entry.getMediaGroup().getDescription().getPlainTextContent()); } } 3/9 YouTube API with Java step-by-step 08. 05. 18 PM 10:55 Searching for videos YouTubeQuery . YouTubeService.query() . YouTubeQuery query = new YouTubeQuery(new URL("http://gdata.youtube.com/feeds/api/videos")); // order results by the number of views (most viewed first) query.setOrderBy(YouTubeQuery.OrderBy.VIEW_COUNT); // do not exclude restricted content from the search results query.setIncludeRacy(true); //search for puppies! query.setVideoQuery("puppy"); VideoFeed videoFeed = service.query(query, VideoFeed.class); for(VideoEntry entry : videoFeed.getEntries() ) { System.out.println("Title: " + entry.getTitle().getPlainText()); System.out.println(entry.getMediaGroup().getDescription().getPlainTextContent()); } YouTubeQuery Query feed URLs . URL . http://gdata.youtube.com/feeds/api/videos?vq=keyword&racy=include&orderby=viewCount YouTubeQuery . setAuthor Sets the author of the entry. setMaxResults Sets the maximum number of entries to return at one time. setStartIndex Sets the 1-based index of the first result to be retrieved (for paging). setVideoQuery Sets a search query term. Searches for the specified string in all video metadata, such as titles, tags, and descriptions. setIncludeRacy Indicates whether restricted content should be included in the results. setFormats Specifies a video format or a set of video formats. setOrderBy Sets the order in which to list entries, such as by RELEVANCE, VIEW_COUNT, UPDATED, or RATING. setTime Sets a time period to limit standard feed results to: TODAY, THIS_WEEK, THIS_MONTH, or ALL_TIME. Searching for videos using categories and keywords . KEYWORD_SCHEME , YouTubeQuery query = new YouTubeQuery(new URL("http://gdata.youtube.com/feeds/api/videos")); // a category filter holds a collection of categories to limit the search Query.CategoryFilter categoryFilter1 = new Query.CategoryFilter(); Query.CategoryFilter categoryFilter2 = new Query.CategoryFilter(); //this restricts to videos tagged with the keyword "puppy". categoryFilter1.addCategory(new Category(YouTubeNamespace.KEYWORD_SCHEME, "puppy")); //this restricts to videos in the category of "Comedy". categoryFilter2.addCategory(new Category(YouTubeNamespace.CATEGORY_SCHEME, "Comedy")); // multiple filters mean "AND" in a category query query.addCategoryFilter(categoryFilter1); query.addCategoryFilter(categoryFilter2); VideoFeed videoFeed = service.query(query, VideoFeed.class); for(VideoEntry entry : videoFeed.getEntries() ) { System.out.println("Title: " + entry.getTitle().getPlainText()); System.out.println(entry.getMediaGroup().getDescription().getPlainTextContent()); } CATEGORY_SCHEME . . . Category CategoryFilter A list of all usable categories is available at: http://gdata.youtube.com/schemas/2007/categories.cat. . Searching for videos using developer tags Developer's tag 'xyzzy' . developer's tag . . YouTubeQuery query = new YouTubeQuery(new URL("http://gdata.youtube.com/feeds/api/videos")); Query.CategoryFilter categoryFilter = new Query.CategoryFilter(); categoryFilter.addCategory(new Category(YouTubeNamespace.DEVELOPER_TAG_SCHEME, "xyzzy")); query.addCategoryFilter(categoryFilter); VideoFeed videoFeed = service.query(query, VideoFeed.class); for(VideoEntry entry : videoFeed.getEntries() ) { System.out.println("Title: " + entry.getTitle().getPlainText()); System.out.println(entry.getMediaGroup().getDescription().getPlainTextContent()); } a developer tag , developer key . Uploading videos . HTML form 4/9 YouTube API with Java step-by-step 08. 05. 18 PM 10:55 . Checking upload status Direct upload The image shows the following steps: 1. Your site displays a form in which the user will enter details about the video being uploaded and select the actual video file to upload. 2. The user selects the video file and enters the video details, such as the title, description and category for the video. 3. Your site sends an HTTP POST request to YouTube that contains the authentication token as well as the video file and the video details that the user submitted in the previous step. The Uploading video metadata section explains how to submit video files and video details to YouTube. 4. YouTube returns an API response describing the new video. 5. You display a confirmation to the user that the video was uploaded successfully. VideoEntry Quictime Video "file.mov" "file.mov" . Property Title Category Keywords Description Filename File MIME type Video private? Video location Developer tag Value testing Autos foo my description file.mov video/quicktime false 37,-122 (lat,long) xyzzy . . VideoEntry newEntry = new VideoEntry(); newEntry.setGeoCoordinates(new GeoRssWhere(37.0,-122.0)); //alternatively, one could specify just a descriptive string newEntry.setLocation("Mountain View, CA"); YouTubeMediaGroup mg = newEntry.getOrCreateMediaGroup(); mg.addCategory(new MediaCategory(YouTubeNamespace.CATEGORY_SCHEME, "Autos")); mg.addCategory(new MediaCategory(YouTubeNamespace.DEVELOPER_TAG_SCHEME, "xyzzy")); mg.setPrivate(false); mg.setTitle(new MediaTitle()); mg.getTitle().setPlainTextContent("testing"); mg.setKeywords(new MediaKeywords()); mg.getKeywords().addKeyword("foo"); mg.setDescription(new MediaDescription()); mg.getDescription().setPlainTextContent("my description"); MediaFileSource ms = new MediaFileSource(new File("file.mov"), "video/quicktime"); newEntry.setMediaSource(ms); String uploadUrl = "http://uploads.gdata.youtube.com/feeds/api/users/default/uploads"; VideoEntry createdEntry = service.insert(new URL(uploadUrl), newEntry); Browser-based upload The image shows the following steps: 1. Your site displays a form in which the user will enter details about the video being uploaded. 2. The user enters the video details, such as the title, description and category for the video. 3. Your site sends an HTTP POST request to YouTube that contains the authentication token and the video details that the user submitted in the previous step. The Uploading video metadata section explains how to submit video details to YouTube. 4. YouTube returns a one-time upload token, an encrypted value containing authentication information and video details for the video being uploaded. The Extracting values from the API response section identifies the upload token and URL in the API response. 5. Your site displays a form where the user can select his video file and upload it to YouTube. The form will submit directly to YouTube and must contain a hidden input field that specifies the upload token obtained in the previous step. The Uploading the video file section defines the guidelines for this form. 6. The user selects his video and submits the form, sending his video and the upload token directly to YouTube. YouTube verifies the token is valid and adds the video to the user's YouTube channel. During this process, YouTube assigns the video a unique ID, which will be used to identify the video on YouTube. 7. YouTube redirects the user back to your site. . URL URL http://gdata.youtube.com/action/GetUploadToken MediaFileSource VideoEntry . 5/9 YouTube API with Java step-by-step 08. 05. 18 PM 10:55 VideoEntry newEntry = new VideoEntry(); newEntry.setGeoCoordinates(new GeoRssWhere(37.0,-122.0)); //alternatively, one could specify just a descriptive string newEntry.setLocation("Mountain View, CA"); YouTubeMediaGroup mg = newEntry.getOrCreateMediaGroup(); mg.addCategory(new MediaCategory(YouTubeNamespace.CATEGORY_SCHEME, "Autos")); mg.addCategory(new MediaCategory(YouTubeNamespace.DEVELOPER_TAG_SCHEME, "xyzzy")); mg.setTitle(new MediaTitle()); mg.setPrivate(false); mg.getTitle().setPlainTextContent("testing"); mg.setKeywords(new MediaKeywords()); mg.getKeywords().addKeyword("foo"); mg.setDescription(new MediaDescription()); mg.getDescription().setPlainTextContent("my description"); URL uploadUrl = new URL("http://gdata.youtube.com/action/GetUploadToken"); FormUploadToken token = service.getFormUploadToken(uploadUrl, newEntry); System.out.println(token.getUrl()); System.out.println(token.getToken()); token.getUrl() HTML form post_url . token.getToken() token_value In order for the user to be redirected to your website after submitting the form, make sure to append a nexturl parameter to the post_url above, which functions identically to the next parameter of an AuthSub link. Checking upload status feed . http://gdata.youtube.com/feeds/api/users/default/uploads However, it will not be public on the site until it has been processed. Videos that have been rejected or failed to upload successfully will also only be in the authenticated user's uploads feed. The following code checks the status of a VideoEntry to see if it is not live yet or if it has been rejected. if(entry.isDraft()) { System.out.println("Video is not live"); YtPublicationState pubState = entry.getPublicationState(); if(pubState.getState() == YtPublicationState.State.PROCESSING) { System.out.println("Video is still being processed."); } else if(pubState.getState() == YtPublicationState.State.REJECTED) { System.out.print("Video has been rejected because: "); System.out.println(pubState.getDescription()); System.out.print("For help visit: "); System.out.println(pubState.getHelpUrl()); } else if(pubState.getState() == YtPublicationState.State.FAILED) { System.out.print("Video failed uploading because: "); System.out.println(pubState.getDescription()); System.out.print("For help visit: "); System.out.println(pubState.getHelpUrl()); } } Updating and deleting videos Updating video information , VideoEntry . entry.getMediaGroup().getDescription().setPlainTextContent("new description"); entry.update(); update method . Deleting a video delet videoEntry.delete(); VideoEntry delete . Using community features Adding a rating , Rating VideoEntry VideoEntry POST . String ratingUrl = entry.getRatingLink().getHref(); Rating myRating = new Rating(); myRating.setValue(5); myRating.setMax(5); myRating.setMin(1); entry.setRating(myRating); service.insert(new URL(ratingUrl), entry); Comments Retrieving video comments VideoEntry . String commentUrl = videoEntry.getComments().getFeedLink().getHref(); CommentFeed commentFeed = service.getFeed(new URL(commentUrl), CommentFeed.class); for(CommentEntry comment : commentFeed.getEntries()) { System.out.println(comment.getPlainTextContent()); } , . Adding a comment commentURL , . CommentEntry newComment = new CommentEntry(); newComment.setContent(new PlainTextConstruct("my pithy comment")); service.insert(new URL(commentUrl), newComment); 6/9 YouTube API with Java step-by-step 08. 05. 18 PM 10:55 Saving and collecting videos Favorite videos Retrieving a user's favorite videos favorite videos favorites feed URL . . favorite videos unnamed playlist . http://gdata.youtube.com/feeds/api/users/userID/favorites String feedUrl = "http://gdata.youtube.com/feeds/api/users/YTDebates/favorites"; VideoFeed videoFeed = service.getFeed(new URL(feedUrl), VideoFeed.class); for(VideoEntry entry : videoFeed.getEntries() ) { System.out.println("Title: " + entry.getTitle().getPlainText()); System.out.println(entry.getMediaGroup().getDescription().getPlainTextContent()); } userID default . Adding a favorite favorite VideoEntry feed insert . String videoEntryUrl = "http://gdata.youtube.com/feeds/api/videos/ADos_xW4_J0"; VideoEntry videoEntry = service.getEntry(new URL(videoEntryUrl), VideoEntry.class); service.insert(new URL(feedUrl), videoEntry); Deleting a favorite favorite entry.delete(); VideoEntry delete . Playlists Retrieving user playlists http://gdata.youtube.com/feeds/api/users/userID/playlists String feedUrl = "http://gdata.youtube.com/feeds/api/users/YTdebates/playlists"; PlaylistLinkFeed feed = service.getFeed(new URL(feedUrl), PlaylistLinkFeed.class); for(PlaylistLinkEntry entry : feed.getEntries()) { System.out.println("Title: " + entry.getTitle().getPlainText()); System.out.println("Description: " + entry.getDescription()); } userID default . Retrieving playlist information PlaylistLinkEntry String playlistUrl = entry.getFeedLink().getHref(); PlaylistFeed playlistFeed = service.getFeed(new URL(playlistUrl), PlaylistFeed.class); for(PlaylistEntry playlistEntry : playlistFeed.getEntries()) { System.out.println("Title: " + playlistEntry.getTitle().getPlainText()); System.out.println("Description: " + playlistEntry.getDescription()); System.out.println("Position: " + playlistEntry.getPosition()); System.out.println("Video URL: " + playlistEntry.getHtmlLink().getHref()); } . PlaylistEntry VideoEntry VideoEntry . Video entry contents. Adding a playlist PlaylistLinkEntry feed . String feedUrl = "http://gdata.youtube.com/feeds/api/users/default/playlists"; PlaylistLinkEntry newEntry = new PlaylistLinkEntry(); newEntry.setTitle(new PlainTextConstruct("new playlist")); newEntry.setDescription("this is my new playlist."); PlaylistLinkEntry createdEntry = service.insert(new URL(feedUrl), newEntry); Updating a playlist PlaylistLinkEntry entry.setDescription("updated description"); entry.update(); update . Add video to playlist VideoEntry VideoEntry (position) . PlaylistLinkEntry . . String playlistUrl = playlistLinkEntry.getFeedLink().getHref(); String videoEntryUrl = "http://gdata.youtube.com/feeds/api/videos/ADos_xW4_J0"; VideoEntry videoEntry = service.getEntry(new URL(videoEntryUrl), VideoEntry.class); PlaylistEntry playlistEntry = new PlaylistEntry(videoEntry); playlistEntry.setTitle(new PlainTextConstruct("Custom title")); playlistEntry.setDescription("Custom description"); service.insert(new URL(playlistUrl), playlistEntry); . Edit video info on playlist PlaylistEntry update playlistEntry.setDescription("updated description"); . 7/9 YouTube API with Java step-by-step 08. 05. 18 PM 10:55 //move this entry to the top of the playlist playlistEntry.setPosition(0); playlistEntry.update(); playlistEntry.setDescription(null); playlistEntry.setTitle(null); playlistEntry.update(); Remove video from playlist PlaylistEntry delete playlistEntry.delete(); Deleting a playlist PlaylistLinkEntry entry.delete(); delete Subscriptions Retrieving user subscriptions URL subscriptions( ) http://gdata.youtube.com/feeds/api/users/userID/subscriptions String feedUrl = "http://gdata.youtube.com/feeds/api/users/GoogleDevelopers/subscriptions"; SubscriptionFeed feed = service.getFeed(new URL(feedUrl), SubscriptionFeed.class); for(SubscriptionEntry entry : feed.getEntries()) { System.out.println("Title: " + entry.getTitle().getPlainText()); System.out.println("Feed Link: " + entry.getFeedLink().getHref()); } userID default . Adding a subscription SubscriptionEntry GoogleDevelopers feed . . SubscriptionEntry newSubscription = new SubscriptionEntry(); newSubscription.addSubscriptionType(SubscriptionEntry.Type.CHANNEL); newSubscription.setUsername("GoogleDevelopers"); service.insert(new URL(feedUrl), newSubscription); "GoogleDevelopers" favorites . SubscriptionEntry newSubscription = new SubscriptionEntry(); newSubscription.addSubscriptionType(SubscriptionEntry.Type.FAVORITES); newSubscription.setUsername("GoogleDevelopers"); service.insert(new URL(feedUrl), newSubscription); SubscriptionEntry newSubscription = new SubscriptionEntry(); newSubscription.addSubscriptionType(SubscriptionEntry.Type.QUERY); newSubscription.setQueryString("puppy"); service.insert(new URL(feedUrl), newSubscription); Deleting a subscription SubscriptionEntry entry.delete(); delete . Enabling user interaction Profiles Retrieving a user's profile URL . http://gdata.youtube.com/feeds/api/users/userID . String profileUrl = "http://gdata.youtube.com/feeds/api/users/YTdebates"; UserProfileEntry profileEntry = service.getEntry(new URL(profileUrl), UserProfileEntry.class); System.out.println("Username: " + profileEntry.getUsername()); System.out.println("Age : " + profileEntry.getAge()); System.out.println("Gender : " + profileEntry.getGender()); System.out.println("Single? : " + profileEntry.getRelationship()); System.out.println("Books : " + profileEntry.getBooks()); System.out.println("Company : " + profileEntry.getCompany()); System.out.println("Describe: " + profileEntry.getDescription()); System.out.println("Hobbies : " + profileEntry.getHobbies()); System.out.println("Hometown: " + profileEntry.getHometown()); System.out.println("Location: " + profileEntry.getLocation()); System.out.println("Movies : " + profileEntry.getMovies()); System.out.println("Music : " + profileEntry.getMusic()); System.out.println("Job : " + profileEntry.getOccupation()); System.out.println("School : " + profileEntry.getSchool()); YtUserProfileStatistics stats = profileEntry.getStatistics(); if(stats != null) { System.out.println("Subscriber count: " + stats.getSubscriberCount()); System.out.println("Last web access: " + stats.getLastWebAccess().toUiString()); } userID default . Messages . . Retrieving user messages 8/9 YouTube API with Java step-by-step 08. 05. 18 PM 10:55 inbox , URL . http://gdata.youtube.com/feeds/api/users/userID/inbox inbox . String feedUrl = "http://gdata.youtube.com/feeds/api/users/default/inbox"; VideoMessageFeed feed = service.getFeed(new URL(feedUrl), VideoMessageFeed.class); for(VideoMessageEntry entry : feed.getEntries()) { System.out.println("Message from: " + entry.getAuthors().get(0).getName()); System.out.println("Subject: " + entry.getTitle().getPlainText()); System.out.println(entry.getDescription()); } Sending a message to a user VideoEntry receivingUser String msgUrl = "http://gdata.youtube.com/feeds/api/users/"+receivingUser+"/inbox"; String videoEntryUrl = "http://gdata.youtube.com/feeds/api/videos/Wegp-JOae0g"; VideoEntry videoEntry = service.getEntry(new URL(videoEntryUrl), VideoEntry.class); VideoMessageEntry newMessage = new VideoMessageEntry(videoEntry); newMessage.setTitle(new PlainTextConstruct("my subject")); newMessage.setDescription("This is the message body."); service.insert(new URL(msgUrl), newMessage); VideoMessageEntry . inbox feed insert . (The recipient) Deleting a message VideoMessageEntry entry.delete(); delete 9/9

Related docs
premium docs
Other docs by amberp
Hess v Pawloski
Views: 911  |  Downloads: 7
Alternative_Exits_Conference
Views: 204  |  Downloads: 1
Farley v Champs Fine Foods
Views: 198  |  Downloads: 1
Guaranty of equipment lease
Views: 283  |  Downloads: 6
Contract of receiver
Views: 223  |  Downloads: 1
Con Law IR outline
Views: 302  |  Downloads: 7
Heart of Worship
Views: 269  |  Downloads: 5
Bill of sale by liquidating trustees
Views: 197  |  Downloads: 1
A Memoir of Growing up Iranian in America
Views: 774  |  Downloads: 6
He is Exalted
Views: 408  |  Downloads: 3
Weight Management Exercise for Health
Views: 359  |  Downloads: 6
Make Me a Servant
Views: 459  |  Downloads: 2
Undivided Heart
Views: 175  |  Downloads: 0
Create In Me
Views: 205  |  Downloads: 3
Cheney Brothers v Doris Silk Corp
Views: 346  |  Downloads: 2