I’m trying to get the user’s subscriptions list. You can only get 50 at a time so i would like to create a batch processing to do all at once.
I’m using Jquery and ajax to send a POST request like this :
var query = "<feed xmlns='http://www.w3.org/2005/Atom'";
query += "xmlns:media='http://search.yahoo.com/mrss/'";
query += "xmlns:batch='http://schemas.google.com/gdata/batch'"
query += "xmlns:yt='http://gdata.youtube.com/schemas/2007'>";
for(var i = 0; i < loop; ++i)
{
query += '<entry>';
query += '<id>http://gdata.youtube.com/feeds/api/users/' + youtube_username + '/subscriptions?max-results=50&start-index=' + ((i * 50) + 1) + '&alt=json</id>';
query += "<batch:operation type='query'/>";
query += '</entry>';
}
query += '</feed>';
$.ajax({
type: 'POST',
url: 'http://gdata.youtube.com/feeds/api/users/batch?v=2',
data: query,
contentType:"application/atom+xml",
dataType:"xml",
success: function(data){
alert(data);
}
});
When I do this request I get an error 400 (bad url request). Then I tried with this URL for entries :
query += '<id>http://gdata.youtube.com/feeds/api/users/' + youtube_username + '/subscriptions/</id>';
But I got this error :
Element type “feed” must be followed by either attribute specifications, “>” or “/>”.
Thank you and have a nice day,
Kevin
“Batch processing requests support query (GET) operations for feed entries but not for entire feeds. For example, if you are sending a batch request for a playlist, you can include one or more entries that retrieve information about individual playlist entries. However, the batch request cannot retrieve the playlist feed that contains those entries.”, as documented in https://developers.google.com/youtube/2.0/developers_guide_protocol_batch_processing
I prefer explain on this way:
Assume subscriptions is what you want process with batch. You open
http://gdata.youtube.com/feeds/api/users/google/subscriptions?v=2&alt=json&prettyprint=True
curl -vLk -d "<feed xmlns='http://www.w3.org/2005/Atom' xmlns:media='http://search.yahoo.com/mrss/' xmlns:batch='http://schemas.google.com/gdata/batch' xmlns:yt='http://gdata.youtube.com/schemas/2007'><batch:operation type='query'/><entry><id>http://gdata.youtube.com/feeds/api/users/google/subscriptions/X7RMFNKroIVT2j3zlJcZK7VKfC7MoH_jycANXotcvEI?v=2</id></entry></feed>" -X POST "http://gdata.youtube.com/feeds/api/users/google/subscriptions/batch?v=2"Another example is video, such as:
curl -vLk -d “http://www.w3.org/2005/Atom’ xmlns:media=’http://search.yahoo.com/mrss/‘ xmlns:batch=’http://schemas.google.com/gdata/batch‘ xmlns:yt=’http://gdata.youtube.com/schemas/2007‘>https://gdata.youtube.com/feeds/api/videos/EWKcFuluXpo” -X POST “https://gdata.youtube.com/feeds/api/videos/batch?v=2“
And user/channel’s info example, such as:
curl -vLk -d “http://www.w3.org/2005/Atom’ xmlns:media=’http://search.yahoo.com/mrss/‘ xmlns:batch=’http://schemas.google.com/gdata/batch‘ xmlns:yt=’http://gdata.youtube.com/schemas/2007‘>http://gdata.youtube.com/feeds/api/users/GoogleDevelopers” -X POST “http://gdata.youtube.com/feeds/api/users/batch?v=2“
So, i don’t think it’s possible query list of subscriptions by batch processing, without knowing the entry id in the first place.