mixcloud
mixcloud copied to clipboard
Gem dosn't work
Hi, when i try to create any object, it raise error:
$ irb
2.1.4 :001 > require 'mixcloud'
=> true
2.1.4 :002 >
2.1.4 :003 > # Examples
2.1.4 :004 >
2.1.4 :005 > makoto = Mixcloud::User.new('http://api.mixcloud.com/makoto')
NoMethodError: undefined method `concat' for nil:NilClass
I test any ruby versions, and has different errors:
2.1.4 :002 > makoto = Mixcloud::User.new('http://api.mixcloud.com/makoto')
NoMethodError: undefined method `strip' for nil:NilClass
How make gem works with MixCloud API?
@deepsystm It was been a while since I worked on this repo. That was still in the ruby 1.9.3 times. May have to revamp the repo soon
+1 Test code doesn't work, same error
+1 I tried to use the gem to access the "/me/" shortcut in my app, but received the "undefined method `playlists_url' for nil:NilClass
When I use curl to load the api URL with my access token in the shell, it returns the correct hash. When I use Mixcloud::User.new to load the same api URL, it returns nil.
@actfong Any plans to revisit the repo and fix to this gem soon?
@actfong if you decide to revamp the repo soon, would be great to see examples for uploads as well!!
@brennnnan I got tired of waiting for an update and used HTTParty to retrieve a token and get the data I needed from the Mixcloud API instead. In case it's helpful, here's how I did it:
@source = HTTParty.get("https://www.mixcloud.com/oauth/access_token?client_id="+Rails.application.credentials.dig(:mixcloud,:client_id)+"&client_secret="+Rails.application.credentials.dig(:mixcloud,:secret)+"&redirect_uri=http://localhost:3000/path/to/mixcloud/callback/&code=#{params[:code]}").parsed_response
@playlist = @source[:data]
unless @playlist.nil? || @playlist.size < 1
@playlist.size.times do
# do something with the data returned
end
else
flash[:alert] = "Sorry, nothing is available from this source."
end
I'm sure you can use Faraday as a replacement for HTTParty, but keep in mind you'll have to add your secret keys to config/credentials.yml.enc using rails credentials:edit
from the command line in Rails 5.2 and above. Hope this helps.