web api youtube api

84
Web API Youtube API Thành viên: Châu Hoàn Sơn – 0912392 Nguyễn Quốc Nhã – 0912317 Huỳnh Văn Lộc – 0912268

Upload: petra-sutton

Post on 02-Jan-2016

106 views

Category:

Documents


0 download

DESCRIPTION

Web API Youtube API. Thành viên : Châu Hoàn Sơn – 0912392 Nguyễn Quốc Nhã – 0912317 Huỳnh Văn Lộc – 0912268. Nội dung tìm hiểu. Khái niệm Web API Lợi ích của Web API Các dạng Web API được cung cấp Cách sử dụng chung cho Web API Giới thiệu Youtube API - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Web API Youtube API

Web APIYoutube API

Thành viên:Châu Hoàn Sơn – 0912392Nguyễn Quốc Nhã – 0912317Huỳnh Văn Lộc – 0912268

Page 2: Web API Youtube API

I. Khái niệm Web APIII. Lợi ích của Web APIIII. Các dạng Web API được cung cấpIV. Cách sử dụng chung cho Web APIV. Giới thiệu Youtube APIVI. Một số API mà Youtube hỗ trợVII. Demo

Nội dung tìm hiểu

Page 3: Web API Youtube API

Khái niệm

Page 4: Web API Youtube API

Là 1 dạng thể hiện, giúp phát triển ứng dụng 1 cách dễ dàng qua việc hỗ trợ rất nhiều những hoạt động / dịch vụ giúp cho người dùng có thể tương tác với hệ thống.

Việc tương tác đó có thể được định nghĩa qua các hàm, các tham số, các biến có liên quan đến hệ thống chính.

API: Application Programming Interface

(Giao diện lập trình ứng dụng)

Page 5: Web API Youtube API

VD: Window có các API để tương tác với các service của hệ thống, các phần mềm mặc định…

API: Application Programming Interface

(Giao diện lập trình ứng dụng)

Page 6: Web API Youtube API

Web API: là API dưới dạng Web Services Là hệ thống thiết lập các thông điệp dạng

HTTP, NET/TCP,.. để gửi lên web, sau đó nhận các thông điệp phản hồi về (thường là dạng JSON, XML có cấu trúc rõ ràng).

Web API

Page 7: Web API Youtube API

Cung cấp cho người dùng 1 dạng các thể hiện, giúp cho người dùng có thể tương tác được với dịch vụ được cung cấp trên web

Người dùng thông qua API để sử dụng các dịnh vụ đó

VD: các hàm, các giao thức, gói tin gửi đi, các URL,..

Web API

Page 8: Web API Youtube API

Lợi ích của Web API

Page 9: Web API Youtube API

Giải quyết vấn đề về dung lượng lưu trữ, tốc độ xử lý….

Cập nhật realtime (thời gian thực) Tăng tính tiện dụng Giảm thời gian, chi phí khi phát triển ứng

dụng …

Lợi ích của Web API

Page 10: Web API Youtube API

Các dạng Web API được cung cấp

Page 11: Web API Youtube API

Địa chỉ Web của API:Mỗi API sẽ có địa chỉ web tương ứng, truy

vấn các địa chỉ này và các tham số truyền vào để sử dụng.

VD: Google map: http://maps.googleapis.com/maps/api/

Google Translator: http://translate.googleapis.com/translate_static

Yahoo! Map Service: http://local.yahooapis.com/MapsService/

Các dạng Web API được cung cấp

Page 12: Web API Youtube API

Các thư viện động: Web API được đóng gói trong 1 bộ thư

viện. Khi sử dụng, gọi các hàm trong đó để sử dung, tương tác với dịch vụ ở trên Net.

VD: Facebook SDK, Youtube Data API..

Các dạng Web API được cung cấp

Page 13: Web API Youtube API

Các thư viện Javascript:Dùng cho việc sử dụng Web API nhúng

vào trong website của người dùng (có dạng gần giống với cách sử dụng địa chỉ web API)

VD: Google, Youtube, Youtube Player API,..

Các dạng Web API được cung cấp

Page 14: Web API Youtube API

Cách sử dụng chung cho Web

API

Page 15: Web API Youtube API

Đối với Web API dạng Link: Dùng các Http Request để thực hiện

việc truy vấn đến web service và nhận dữ liệu.

Các Http Request là các link tương ứng từng dịch vụ mà hệ thống đó hỗ trợ; truyền vào các tham số, sau đó dùng nó để truy vấn lên hệ thống trên Web, hệ thống sẽ xử lý và trả về kết quả.

Cách sử dụng chung cho Web API

Page 16: Web API Youtube API

VD: đoạn code sau sẽ truy vấn lên Yahoo API, tìm và lấy “Tên” của tỉnh ở tọa độ Kinh độ, Vĩ độ được truyền vào. Kết quả trả về là 1 file Json, trong đó có tên của tỉnh cần lấy.

public WebClient webClient; Uri uri = new Uri( "http://where.yahooapis.com/geocode?&gflags=R&location=“+ [kinh độ] + "+" + [vĩ độ]); webClient.DownloadStringAsync(uri);

Cách sử dụng chung cho Web API

Đối với Web API dạng Link:

Page 17: Web API Youtube API

Đối với Web API dạng SDK: Download và cài đặt SDK Add reference và sử dụng những phương

thức mà Web API cung cấp

VD: Youtube API:https://code.google.com/p/google-gdata/downloads/

list

 

Cách sử dụng chung cho Web API

Page 18: Web API Youtube API

Đối với Web API dạng SDK:

Feed<Video> videoFeed = request.Get<Video>(new Uri(feedUrl));printVideoFeed(videoFeed);

static void printVideoFeed(Feed<Video> feed){ foreach (Video entry in feed.Entries) {

printVideoEntry(entry); }}

Cách sử dụng chung cho Web API

VD: Hiện video feed

Page 19: Web API Youtube API

Đối với Web API dạng thư viện Java Script:Sử dụng chính các link đến Web API đó để

lấy thông tin, khởi tạo các giá trị cho đối tượng và thực hiện

VD: link đến google map api để lấy file javascript , hiển thị google map và các phím control trên trình duyệt.

Cách sử dụng chung cho Web API

Page 20: Web API Youtube API

Đối với Web API dạng thư viện Java Script:

Cách sử dụng chung cho Web API

Page 21: Web API Youtube API

Giới thiệuYoutube API

Page 22: Web API Youtube API

Giới thiệu Youtube

Là Website chia sẻ video hàng đầu thế giới Số lượt sử dụng hàng ngày của Youtube

đến hơn 200.000 lượt (thống kê 2010). Người dùng có thể đăng tải các video,

comment, lưu video vào danh sách ưa thích, tạo page riêng,.. và nhiều ứng dụng khác.

Địa chỉ truy cập: www.youtube.com

Page 23: Web API Youtube API

Youtube API được cung cấp theo 2 dạng:Data API và Player API

Data API:Cho phép người dùng có thể thực hiện

nhiều thao tác tương tự trên website Youtube: Upload video, Sửa đổi danh sách ưa thích, tìm kiếm, comment, đánh giá,..

Giới thiệu Youtube API

Page 24: Web API Youtube API

Player API:Cho phép người dùng nhúng đoạn video

vào trong trang web và có thể thực hiện các thao tác Play, Pause, Stop, tăng giảm âm lượng,.. trực tiếp từ web của họ mà không phải thông qua Youtube.

Giới thiệu Youtube API

Page 25: Web API Youtube API

Một số API mà Youtube hỗ trợ

Page 26: Web API Youtube API

I. Chứng thực II. Video feed và entryIII. Truy xuất và tìm kiếm videoIV. Upload videoV. Cập nhật và xoá videoVI. Sử dụng tính năng cộng đồngVII. Lưu trữ và chọn lựa videoVIII. Kích hoạt tương tác người

dùng

Một số API mà Youtube hỗ trợ

Page 27: Web API Youtube API

Một số API mà Youtube hỗ trợ

Chứng thực

Page 28: Web API Youtube API

Chứng thực việc sử dụng Youtube API

YouTubeRequestSettings settings = new YouTubeRequestSettings("example app", developerKey);YouTubeRequest request = new YouTubeRequest(settings);

Một số API mà Youtube hỗ trợChứng thực

DeveloperKey: http://code.google.com/apis/youtube/dashboard

Page 29: Web API Youtube API

Một số API mà Youtube hỗ trợ

Video feed và entry

Page 30: Web API Youtube API

Truy xuất video feed

Feed<Video> videoFeed = request.Get<Video>(new Uri(feedUrl));printVideoFeed(videoFeed);

static void printVideoFeed(Feed<Video> feed){ foreach (Video entry in feed.Entries) {

printVideoEntry(entry); //xem mục 1.3 video entry contents }}

Một số API mà Youtube hỗ trợVideo feed và entry

Page 31: Web API Youtube API

Truy xuất video feed

Một số API mà Youtube hỗ trợVideo feed và entry

Page 32: Web API Youtube API

Truy xuất video entry qua id

Một số API mà Youtube hỗ trợVideo feed và entry

Uri  videoEntryUrl = new Uri("http://gdata.youtube.com/feeds/api/videos/ADos_xW4_J0");

Video video = request.Retrieve<Video>(videoEntryUrl);printVideoEntry(video);

Page 33: Web API Youtube API

Truy xuất video entry qua id

Một số API mà Youtube hỗ trợVideo feed và entry

Page 34: Web API Youtube API

Nội dung của video entry:Sử dụng các thuộc tính sau:

Một số API mà Youtube hỗ trợVideo feed và entry

video.Title video.Description video.Keywords video.Uploader video.YouTubeEntry video.Media

video.Status video.ReadOnly video.RatingAverag

e video.Contents …

Page 35: Web API Youtube API

Nội dung của video entry:

Một số API mà Youtube hỗ trợVideo feed và entry

Page 36: Web API Youtube API

Một số API mà Youtube hỗ trợ

Truy xuất vàtìm kiếm video

Page 37: Web API Youtube API

Truy xuất feed theo chuẩn

Một số API mà Youtube hỗ trợTruy xuất và tìm kiếm video

Feed Name Feed Identifier

Most Viewed most_viewed

Top Rated top_rated

Recently Featured recently_featured

Watch On Mobile watch_on_mobile

Most Discussed most_discussed

Top Favorites top_favorites

Most Responded most_responded

Most Recent most_recent

Page 38: Web API Youtube API

Truy xuất feed theo chuẩn

Một số API mà Youtube hỗ trợTruy xuất và tìm kiếm video

http://gdata.youtube.com/feeds/api/standardfeeds

/FEED_IDENTIFIERhttp://gdata.youtube.com/feeds/api/

standardfeeds/localeID/

feedID_CATEGORY_NAME

VD: http://gdata.youtube.com/feeds/api/standardfeeds/JP/

top_rated_Comedy

Page 39: Web API Youtube API

Truy xuất feed theo chuẩn

Một số API mà Youtube hỗ trợTruy xuất và tìm kiếm video

Feed<Video> videoFeed = request.GetStandardFeed(YouTubeQuery.MostPopular);printVideoFeed(videoFeed);

Page 40: Web API Youtube API

Truy xuất feed theo chuẩn

Một số API mà Youtube hỗ trợTruy xuất và tìm kiếm video

Page 41: Web API Youtube API

Truy xuất video feed upload bởi người dùng

Một số API mà Youtube hỗ trợTruy xuất và tìm kiếm video

http://gdata.youtube.com/feeds/api/users/username/uploadshttp://gdata.youtube.com/feeds/api/users/username/uploads/VIDEO_IDhttp://gdata.youtube.com/feeds/api/users/default/uploads (lấy feed dựa vào quyền user đã chứng thực)

VD: Uri uri = new Uri("http://gdata.youtube.com/feeds/api

/users/GoogleDevelopers/uploads");

Feed<Video> videoFeed = request.Get<Video>(uri); printVideoFeed(videoFeed);

Page 42: Web API Youtube API

Truy xuất video feed upload bởi người dùng

Một số API mà Youtube hỗ trợTruy xuất và tìm kiếm video

Page 43: Web API Youtube API

Lấy những video liên quan

Một số API mà Youtube hỗ trợTruy xuất và tìm kiếm video

Uri videoEntryUrl = new Uri( "http://gdata.youtube.com/feeds/api/videos/ADos_xW4_J0");Video video = request.Retrieve<Video>(videoEntryUrl);Feed<Video> relatedVideos = request.GetRelatedVideos(video);printVideoFeed(relatedVideos)

Page 44: Web API Youtube API

Lấy những video liên quan

Một số API mà Youtube hỗ trợTruy xuất và tìm kiếm video

Page 45: Web API Youtube API

Tìm kiếm video

Một số API mà Youtube hỗ trợTruy xuất và tìm kiếm video

YouTubeQuery query = new YouTubeQuery(YouTubeQuery.DefaultVideoUri);

//order results by the number of views (most viewed first)query.OrderBy = "viewCount";

Ta sử dụng mẫu URL sau:http://gdata.youtube.com/feeds/api/videos?q=keyword&safeSearch=none&orderby=viewCount

VD:

Page 46: Web API Youtube API

Tìm kiếm video

Một số API mà Youtube hỗ trợTruy xuất và tìm kiếm video

// search for puppies and include restricted content in the search results// query.SafeSearch could also be set to YouTubeQuery.SafeSearchValues.Moderatequery.Query = "puppy";query.SafeSearch = YouTubeQuery.SafeSearchValues.None;

Feed<Video> videoFeed = request.Get<Video>(query);

printVideoFeed(videoFeed);

Page 47: Web API Youtube API

Tìm kiếm video

Một số API mà Youtube hỗ trợTruy xuất và tìm kiếm video

Page 48: Web API Youtube API

Tìm kiếm video sử dụng category và keyword

Một số API mà Youtube hỗ trợTruy xuất và tìm kiếm video

YouTubeQuery query = new YouTubeQuery(YouTubeQuery.DefaultVideoUri);

AtomCategory category1 = new AtomCategory("News", YouTubeNameTable.CategorySchema);AtomCategory category2 = new AtomCategory("sports", YouTubeNameTable.KeywordSchema); query.Categories.Add(new QueryCategory(category1));query.Categories.Add(new QueryCategory(category2));

Feed<Video> videoFeed = request.Get<Video>(query);printVideoFeed(videoFeed);

Page 49: Web API Youtube API

Tìm kiếm video sử dụng category và keyword

Một số API mà Youtube hỗ trợTruy xuất và tìm kiếm video

Page 50: Web API Youtube API

Một số API mà Youtube hỗ trợ

Upload video

Page 51: Web API Youtube API

Upload video

Một số API mà Youtube hỗ trợUpload video

Video newVideo = new Video();

newVideo.Title ="My Test Movie";newVideo.Tags.Add(new MediaCategory("Autos", YouTubeNameTable.CategorySchema));newVideo.Keywords = "cars, funny";newVideo.Description = "My description";newVideo.YouTubeEntry.Private = false;newVideo.Tags.Add(new MediaCategory("mydevtag, anotherdevtag",   YouTubeNameTable.DeveloperTagSchema));

Page 52: Web API Youtube API

Upload video Trực tiếp

Một số API mà Youtube hỗ trợUpload video

newVideo.YouTubeEntry.Location = new GeoRssWhere(37, -122);// alternatively, you could just specify a descriptive string// newVideo.YouTubeEntry.setYouTubeExtension("location", "Mountain View, CA");

newVideo.YouTubeEntry.MediaSource = new MediaFileSource("c:\\file.mov",  "video/quicktime");Video createdVideo = request.Upload(newVideo);

Page 53: Web API Youtube API

Upload video dựa vào trình duyệt

Một số API mà Youtube hỗ trợUpload video

newVideo.YouTubeEntry.Location = new GeoRssWhere(37, -122);// alternatively, you could just specify a descriptive string// newVideo.YouTubeEntry.setYouTubeExtension("location", "Mountain View, CA");

FormUploadToken token = request.CreateFormUploadToken(newVideo);Console.WriteLine(token.Url);Console.WriteLine(token.Token);

Page 54: Web API Youtube API

Upload video dựa vào trình duyệt

Một số API mà Youtube hỗ trợUpload video

newVideo.YouTubeEntry.Location = new GeoRssWhere(37, -122);// alternatively, you could just specify a descriptive string// newVideo.YouTubeEntry.setYouTubeExtension("location", "Mountain View, CA");

FormUploadToken token = request.CreateFormUploadToken(newVideo);Console.WriteLine(token.Url);Console.WriteLine(token.Token);

Page 55: Web API Youtube API

Kiểm tra trạng thái upload

Một số API mà Youtube hỗ trợUpload video

if (video.IsDraft){ Console.WriteLine("Video is not live."); string stateName = video.Status.Name; if (stateName == "processing") {

Console.WriteLine("Video is still being processed."); } else if (stateName == "rejected“ || stateName == "failed")) {

Console.WriteLine("Video is still being processed."); }

Page 56: Web API Youtube API

Một số API mà Youtube hỗ trợ

Cập nhậtvà Xoá video

Page 57: Web API Youtube API

Cập nhật thông tin video

Một số API mà Youtube hỗ trợCập nhật và Xoá video

video.Description = "new description";Video updatedVideo = request.Update(video);

Xóa videorequest.Delete(video);

Page 58: Web API Youtube API

Một số API mà Youtube hỗ trợ

Sử dụngtính năng cộng đồng

Page 59: Web API Youtube API

Đánh giá video

Một số API mà Youtube hỗ trợSử dụng tính năng cộng đồng

Truy xuất Video Comment

video.Rating = 5;request.Insert(video.RatingsUri, video);

Feed comments = request.GetComments(v);foreach (Comment c in comments.Entries){

Console.WriteLine(c.Content);}

Page 60: Web API Youtube API

Thêm comment

Một số API mà Youtube hỗ trợSử dụng tính năng cộng đồng

Comment c = new Comment();c.Content = "This is my comment.";request.AddComment(video, c);

// retrieve the comments for the videoFeed fc = request.GetComments(video);List comments = new List(fc.Entries); // create a reply to the third commentComment c = comments[2];Comment reply = new Comment(); reply.ReplyTo(c);reply.Content = "This is the reply text"; request.AddComment(video, reply);

Page 61: Web API Youtube API

Truy xuất video responses

Một số API mà Youtube hỗ trợSử dụng tính năng cộng đồng

Uri  videoEntryUrl =   new Uri ("http://gdata.youtube.com/feeds/api/videos/ADos_xW4_J0");Video video = request.Retrieve<Video>(videoEntryUrl);Feed<Video> responses = request.GetResponseVideos(video);printVideoFeed(responses);

Page 62: Web API Youtube API

Thêm video responses

Một số API mà Youtube hỗ trợSử dụng tính năng cộng đồng

request.Insert(video.ResponseUri, responseVideo);

request.Insert(videoFeed, responseVideo);

Thêm video responses

request.Delete(responseVideo);

Page 63: Web API Youtube API

Đánh dấu video

Một số API mà Youtube hỗ trợSử dụng tính năng cộng đồng

Complaint c = new Complaint();c.Type = ComplaintEntry.ComplaintType.PORN;c.Content = "This video offends my better sensibilities.";

request.Insert(video.ComplaintUri, c);

Page 64: Web API Youtube API

Một số API mà Youtube hỗ trợ

Lưu trữvà Thu thập video

Page 65: Web API Youtube API

Truy xuất video yêu thích của người dùng

Một số API mà Youtube hỗ trợLưu trữ và Thu thập video

Feed<Video> feed = request.GetFavoriteVideo(username);printVideoFeed(videoFeed);

Xoá video yêu thíchrequest.Delete(favoriteVideo);

Page 66: Web API Youtube API

Thêm video yêu thích

Một số API mà Youtube hỗ trợ

string videoEntryUrl = "http://gdata.youtube.com/feeds/api/videos/ADos_xW4_J0";YouTubeEntry videoEntry = (YouTubeEntry) service.Get(videoEntryUrl);service.Insert(new Uri(feedUrl), videoEntry);

Lưu trữ và Thu thập video

Page 67: Web API Youtube API

Truy xuất playlist của người dùng

Một số API mà Youtube hỗ trợLưu trữ và Thu thập video

Feed<Playlist> userPlaylists = request.GetPlaylistsFeed(username);foreach (Playlist p in userPlaylists.Entries){  Console.WriteLine("Title: " + p.Title);  Console.WriteLine(p.Summary);  Console.WriteLine("Number of entries: " + p.CountHint);}

Page 68: Web API Youtube API

Truy xuất thông tin playlist

Một số API mà Youtube hỗ trợLưu trữ và Thu thập video

Feed<PlayListMember> list = request.GetPlaylist(p);foreach (Video v in list.Entries){  printVideoEntry(v);}

Page 69: Web API Youtube API

Thêm playlist

Một số API mà Youtube hỗ trợLưu trữ và Thu thập video

Playlist pl = new Playlist();pl.Title = "this is the title";pl.Summary = "this is my new playlist";Playlist createdPlaylist = request.Insert(  new Uri("http://gdata.youtube.com/feeds/api/users/default/playlists"), pl);

Page 70: Web API Youtube API

Xóa playlist

Một số API mà Youtube hỗ trợLưu trữ và Thu thập video

Cập nhật playlist

request.Delete(playlist);

pl.Summary = "updated summary";request.Update(pl);

Page 71: Web API Youtube API

Thêm video vào playlist

Một số API mà Youtube hỗ trợLưu trữ và Thu thập video

// For Playlist object pPlayListMember pm = new PlayListMember();

// Insert <id> or <videoid> for video herepm.Id = VIDEOID;request.AddToPlaylist(p, pm);

Page 72: Web API Youtube API

Sửa thông tin của playlist

Một số API mà Youtube hỗ trợLưu trữ và Thu thập video

// move PlayListMember pm to the top of the playlistpm.Position = 1;request.Update(pm);

request.Delete(playListMember);

Xóa video trong playlist

Page 73: Web API Youtube API

Lấy subscription của người dùng

Một số API mà Youtube hỗ trợLưu trữ và Thu thập video

string feedUrl =  "http://gdata.youtube.com/feeds/api/users/GoogleDevelopers/subscriptions";YouTubeQuery query = new YouTubeQuery(feedUrl);SubscriptionFeed subFeed = service.GetSubscriptions(query);

foreach (SubscriptionEntry entry in subFeed.Entries){  Console.WriteLine("Title: " + entry.Title.Text);  Console.WriteLine(entry.Content.Src.Content);}

Page 74: Web API Youtube API

Thêm subscription

Một số API mà Youtube hỗ trợLưu trữ và Thu thập video

Subscription s = new Subscription();s.Type = SubscriptionEntry.SubcriptionType.channel;s.UserName = "GoogleDevelopers";request.Insert(new Uri(YouTubeQuery.CreateSubscriptionUri(null)), s);

Page 75: Web API Youtube API

Theo dõi 1 danh sách các video yêu thích

Một số API mà Youtube hỗ trợLưu trữ và Thu thập video

Subscription s = new Subscription();s.Type = SubscriptionEntry.SubcriptionType.favorites;s.UserName = "GoogleDevelopers";request.Insert(new Uri(YouTubeQuery.CreateSubscriptionUri(null)), s);

Page 76: Web API Youtube API

Theo dõi Playlist

Một số API mà Youtube hỗ trợLưu trữ và Thu thập video

Subscription s = new Subscription();s.Type = SubscriptionEntry.SubcriptionType.playlist;string playlistId = "586D322B5E2764CF";s.PlaylistId = playlistId;request.Insert(new Uri(YouTubeQuery.CreateSubscriptionUri(null)), s);

Page 77: Web API Youtube API

Theo dõi theo từ khoá tìm kiếm

Một số API mà Youtube hỗ trợLưu trữ và Thu thập video

Subscription s = new Subscription();s.Type = SubscriptionEntry.SubcriptionType.query;s.QueryString = "puppies";request.Insert(new Uri(YouTubeQuery.CreateSubscriptionUri(null)), s);

Xoá subscriptionrequest.Delete(s);

Page 78: Web API Youtube API

Một số API mà Youtube hỗ trợ

Kích hoạttương tác người dùng

Page 79: Web API Youtube API

Truy xuất profile của người dùng

Một số API mà Youtube hỗ trợKích hoạt tương tác người dùng

string feedUrl = "http://gdata.youtube.com/feeds/api/users/GoogleDevelopers";ProfileEntry profile = (ProfileEntry) service.Get(feedUrl);...profile.UserNameprofile.Ageprofile.Genderprofile.Relationshipprofile.Booksprofile.Companyprofile.Description…

Page 80: Web API Youtube API

Truy xuất contact

Một số API mà Youtube hỗ trợKích hoạt tương tác người dùng

string feedUrl = "http://gdata.youtube.com/feeds/api/users/

GoogleDevelopers/contacts";YouTubeQuery query = new YouTubeQuery(feedUrl);FriendsFeed friendFeed = service.GetFriends(query);

Xóa contactfriendEntry.Delete();

Page 81: Web API Youtube API

Truy xuất tin nhắn

Một số API mà Youtube hỗ trợKích hoạt tương tác người dùng

Xóa tin nhắnentry.Delete();

string feedUrl = "http://gdata.youtube.com/feeds/api/users/default/inbox";YouTubeQuery query = new YouTubeQuery(feedUrl);MessageFeed messagesFeed = service.GetMessages(query);

Page 82: Web API Youtube API

Gửi tin nhắn

Một số API mà Youtube hỗ trợKích hoạt tương tác người dùng

string friendsInbox = "http://gdata.youtube.com/feeds/api/users/" + receivingUser + "/inbox";string videoEntryUrl = "http://gdata.youtube.com/feeds/api/videos/ADos_xW4_J0";YouTubeEntry videoEntry = (YouTubeEntry) service.Get(videoEntryUrl);MessageEntry newMessage = new MessageEntry();newMessage.Title.Text = "My Subject";newMessage.Summary.Text = "This is the message body.";newMessage.Id = videoEntry.Id;service.Insert(new Uri(friendsInbox), newMessage);

Page 83: Web API Youtube API

DEMO

Page 84: Web API Youtube API

Thank You !!