5
我有10個youtube頻道,我喜歡,我想獲得每個頻道的最新視頻信息。現在我正在做這樣的10個不同的電話:批量請求與YouTube的API - 從多個頻道獲取最新的視頻信息
http://gdata.youtube.com/feeds/api/users/USERNAME/uploads?v=2&alt=jsonc&start-index=1&max-results=1
我想通過使用批量請求來替換這些10個調用。
我tryed這一點:
String xml = "<feed xmlns='http://www.w3.org/2005/Atom' xmlns:batch='http://schemas.google.com/gdata/batch'>" +
" <batch:operation type='query'/>" +
" <entry>" +
" <id>http://gdata.youtube.com/feeds/api/videos/VIDEO_ID_1</id>" +
" </entry>" +
" <entry>" +
" <id>http://gdata.youtube.com/feeds/api/videos/VIDEO_ID_2</id>" +
" </entry>" +
...
" <entry>" +
" <id>http://gdata.youtube.com/feeds/api/videos/VIDEO_ID_10</id>" +
" </entry>" +
"</feed>";
HttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost("https://gdata.youtube.com/feeds/api/videos/batch?v=2");
StringEntity se = new StringEntity(xml);
se.setContentType("text/xml");
httpPost.setEntity(se);
HttpResponse response = httpClient.execute(httpPost);
我得到與在HttpResponse對象有用數據的XML。
但是,如果我想獲得10個最新的視頻信息,我不會知道videoId。
有沒有人知道如何實現這一目標?
好的!感謝您的回答! –