Created
November 5, 2012 22:04
-
-
Save amolk/4020686 to your computer and use it in GitHub Desktop.
GData batch requests
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# NOTE: This call will result in an error. Apparently queries cannot be batched (https://groups.google.com/forum/?fromgroups=#!searchin/youtube-api-gdata/Invalid$20entry$20Id$2FUri/youtube-api-gdata/2QQSXx8-c4A/UAJ9NhMzgvMJ). | |
# The surrounding xml container for batch requests is valid and is saved here as an example. | |
require 'builder' | |
xml = Builder::XmlMarkup.new; false | |
xml.instruct! :xml, :encoding => "UTF-8" | |
ns = {"xmlns"=>"http://www.w3.org/2005/Atom", "xmlns:openSearch"=>"http://a9.com/-/spec/opensearchrss/1.0/", "xmlns:g"=>"http://base.google.com/ns/1.0", "xmlns:batch"=>"http://schemas.google.com/gdata/batch"} | |
xml.feed(ns) do |feed| | |
feed.title "Channel stats query" | |
feed.entry do |entry| | |
entry.id 'http://gdata.youtube.com/feeds/api/channels?q=machinima&v=2' | |
entry.tag!("batch:operation", :type => "query") | |
end | |
end | |
response = client.post("http://gdata.youtube.com/feeds/api/channels/batch?v=2", xml) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment