0

我编写了一些基本代码来尝试使库正常工作。我在 Windows 7 上运行,我刚刚安装了 youtube_it gem 并尝试运行自述文件中的一些示例代码,但是,我收到了一个令人费解的 ArgumentError。这是我尝试运行的代码:

#Test YouTube Ruby file. 
require 'youtube_it'
client = YouTubeIt::Client.new(:dev_key => "my developer key here)
client.videos_by(:query => "penguin", :max_results => 1)
client.videos.each do |video|
  video.title
  video.video_id
end

For reference, the error received was this: C:/RailsInstaller/Ruby1.9.3/lib/rubygems/1.9.1/gems/youtube_it-2.3.1/lib/youtube_it/request/video_upload.rb:265: in 'videos' wrong number of arguments (0 for 1) (ArgumentError).

任何关于我如何进行故障排除的输入都会很棒。

4

1 回答 1

3

首先,您需要关闭您的开发密钥引号

client = YouTubeIt::Client.new(:dev_key => "my developer key here")

这对我有用:

require 'youtube_it'
client = YouTubeIt::Client.new(:dev_key => "my developer key here")
response = client.videos_by(:query => "penguin")
response.videos.first.title

从那里尝试一些东西:

response.videos.each do |video|
  puts video.title
end

结果:

Pablo Penguin
Emperor penguins - The Greatest Wildlife Show on Earth - BBC
Penguin Fail - Best Bloopers from Penguins Spy in the Huddle
PoM - The Penguin Who Loved Me part 1
Scamper the Penguin (1988) - English Dubbed
Pet Penguin in Japan
Avicii - Penguin (Original mix)
CLUB PENGUIN....
penguin
Penguins very funny
Emperor Penguins in Antarctica
Christina Perri - Penguin (Official Lyric Video)
Club Penguin Unlock Item Codes (NEW) March 2013 Must Watch !!!! (HD)
Emperor Penguins Speed Launch Out of the Water
Avicii - 'Penguin' (Club Mix)
Cookie the Little Penguin at the Cincinnati Zoo
Penguin.avi
DONALD´S PENGUIN  1939
Penguins - BBC
Penguin Dilemma
Very happy Gentoo penguin
Zombie in a Penguin Suit
Penguin One
What should we expect in the next few months in terms of SEO for Google?
槇原敬之 - PENGUIN (2004年 日本武道館)
于 2013-06-24T03:14:13.133 回答