Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/image-processing/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 如何在RubyOnRails中集成SoundCloud?_Ruby On Rails_Ruby_Ruby On Rails 3_Sdk_Soundcloud - Fatal编程技术网

Ruby on rails 如何在RubyOnRails中集成SoundCloud?

Ruby on rails 如何在RubyOnRails中集成SoundCloud?,ruby-on-rails,ruby,ruby-on-rails-3,sdk,soundcloud,Ruby On Rails,Ruby,Ruby On Rails 3,Sdk,Soundcloud,我不熟悉RubyOnRails和SoundCloud 我想在RubyonRails应用程序中集成SoundCloudAPI 为此,我已在上注册,并获得了ClientID和ClientSecret。 我还从link下载了SDK 现在,我已将文件和文件夹从lib和spec目录复制到我的应用程序lib和spec目录。此外,我还在gem文件中添加了gem'soundcloud' 在此之后,我在我的交互程序中制作了简单的代码(从doc复制)- # register a client with YOUR_C

我不熟悉RubyOnRails和SoundCloud

我想在RubyonRails应用程序中集成SoundCloudAPI

为此,我已在上注册,并获得了ClientID和ClientSecret。 我还从link下载了SDK

现在,我已将文件和文件夹从libspec目录复制到我的应用程序lib和spec目录。此外,我还在gem文件中添加了gem'soundcloud'

在此之后,我在我的交互程序中制作了简单的代码(从doc复制)-

# register a client with YOUR_CLIENT_ID as client_id_
client = SoundCloud.new(:client_id => YOUR_CLIENT_ID)
# get 10 hottest tracks
tracks = client.get('/tracks', :limit => 10, :order => 'hotness')
# print each link
tracks.each do |track|
  puts track.permalink_url
end
但这里我得到了一个错误-

uninitialized constant MyApp::Interactors::MyInteractor::MyAction::SoundCloud
我沿着楼梯走。有没有在RubyOnRails中集成SoundCloud的循序渐进的例子,以便我可以遵循

请帮助我解决此错误并将SoundCloud集成到RubyOnRail中

Mycor.rb

module MyApp
  module Interactors
    module MyInteractor

      class MyAction < Struct.new(:user, :params)

        def run
          # SoundCloud
          # register a client with YOUR_CLIENT_ID as client_id_
          client = SoundCloud.new(:client_id => 'my-client-id')
          # get 10 hottest tracks
          tracks = client.get('/tracks', :limit => 10, :order => 'hotness')
          # print each link
          tracks.each do |track|
            puts track.permalink_url
          end

        end

      end      
    end
  end
end
模块MyApp
模块交互器
模块MyInteractor
类MyAction“我的客户id”)
#获得10首最热门的歌曲
tracks=client.get(“/tracks”,:limit=>10,:order=>hotness”)
#打印每个链接
轨道。每个do |轨道|
放置track.permalink\u url
结束
结束
结束
结束
结束
结束

soundcloud github页面中有一个输入错误更改行:

client = SoundCloud.new(:client_id => 'my-client-id')


[注意Soundcloud中的小写c]

此外,您还需要Soundcloud API的客户端机密来验证您的身份

可能将client方法放入控制器或帮助程序中,使client=SoundCloud.new(您的客户端id、密钥和重定向uri)与您的客户端id、客户端机密和重定向uri值一起在.env文件中受保护

我认为,通过省略重定向uri和客户端机密,您可能会在myinteractior.rb中遇到此错误

希望这有帮助

client = Soundcloud.new(:client_id => 'my-client-id')