matthooks / vimeo

A full featured Ruby implementation of the Vimeo API
http://blackholeinthemidwest.com/
MIT License
331 stars 85 forks source link

NoMethodError: undefined method `get_videos' #21

Open simonhutchings opened 13 years ago

simonhutchings commented 13 years ago

No sure why this is. Works fine in Simple mode, but when I use my authentication for the Advanced mode

i do

test = Vimeo::Advanced::Video.new("xxxxx", "xxxxx", :token => "xxxx", :secret => "xxxxx")

I have the appropriate token and secret in db

which generates

<Vimeo::Advanced::Video:0x387e878 @access_token=#<OAuth::AccessToken:0x387e814 @params={}, @consumer=#<OAuth::Consumer:0x387e828 @options={:signature_method=>"HMAC-SHA1", :access_token_path=>"/oauth/access_token", :http_method=>:get, :scheme=>:header, :oauth_version=>"1.0", :site=>"http://vimeo.com", :proxy=>nil, :request_token_path=>"/oauth/request_token", :authorize_path=>"/oauth/authorize"}, @key="xxxxxx", @secret="xxxxxx">, @secret="xxxxxx", @token="xxxxxxx">, @oauth_consumer=#<OAuth::Consumer:0x387e828 @options={:signature_method=>"HMAC-SHA1", :access_token_path=>"/oauth/access_token", :http_method=>:get, :scheme=>:header, :oauth_version=>"1.0", :site=>"http://vimeo.com", :proxy=>nil, :request_token_path=>"/oauth/request_token", :authorize_path=>"/oauth/authorize"}, @key="xxxxxx", @secret="xxxxxx">>

then do

test.get_videos("chamonix")

and I get

NoMethodError: undefined method `get_videos' for #Vimeo::Advanced::Video:0x387e878 from (irb):12

Any ideas

qajaq commented 12 years ago

I'm running into similar problem in the script/console. Inspecting the list of available methods for this object showed "get_uploaded_list", and "get_list". But if I do test.get_uploaded_list I get back a HTML response of "Page not found" from Vimeo. Anybody have any luck?

simonhutchings commented 12 years ago

Got it working in the app

application.rb

  AWS::S3::Base.establish_connection!(
        :access_key_id     => 'xxxxxxx',
        :secret_access_key => 'xxxxxxxx'
      )

my controller for admin_videos (using active_admin)

before_filter :authorise, :only => :index

#adds the video refs from vimeo

def add_videos
  if params['sync'] == "true"
    videos = Vimeo::Simple::User.videos("chamonix")
    videos.each do |video|
      @video_entry = Video.find_or_create_by_video_id(video['id'])
      if @video_entry.title.blank?
        Video.import_info(@video_entry, video)
      end
    end
    #check_exist_on_vimeo
  end
end

def create
  video = Vimeo::Simple::Video.info(params[:video][:video_id])

  if !video.first.blank?
    @video_entry = Video.find_or_create_by_video_id(params[:video][:video_id])

    #uses video model to input the info
    Video.import_info(@video_entry, video.first)
    redirect_to admin_video_path(@video_entry), :notice => "Video Saved!"
  else
    redirect_to new_admin_video_path, :notice => "Could not find this video, try again!"
  end
end

#authorisation script
def authorise
  if params[:oauth_token]
    base = Vimeo::Advanced::Base.new(CUSTOMER_KEY, CUSTOMER_SECRET)
    access_token = base.get_access_token(params[:oauth_token], session[:oauth_secret], params[:oauth_verifier])
    current_admin_user.token = access_token.token
    current_admin_user.secret = access_token.secret
    current_admin_user.save
    redirect_to admin_videos_path
  end

  if current_admin_user.token.blank?
    base = Vimeo::Advanced::Base.new(CUSTOMER_KEY, CUSTOMER_SECRET)
    request_token = base.get_request_token
    session[:oauth_secret] = request_token.secret

    redirect_to base.authorize_url
  else
    @vimeo_access = Vimeo::Advanced::Video.new(CUSTOMER_KEY, CUSTOMER_SECRET, :token => current_admin_user.token, :secret => current_admin_user.secret)
  end
end

if interested check out http://www.sebmontaz.com theres some great footage on there, in the process of building a store for it

qajaq commented 12 years ago

Awesome! Thanks for the quick response. Will give it a shot.