Code Monkey home page Code Monkey logo

rdio-simple's Introduction

rdio-simple

a set of simple clients libraries for Rdio's web API.


These libraries for Python, PHP, Ruby, Node.js and Java implement the subset of OAuth that is required to talk to the Rdio service with minimal external dependencies.

Documentation is at: http://www.rdio.com/developers/docs/libraries/simple/ Examples for each language are under each language directory.

Testing

There is a testing framework that verifies that the languages implement request signing consistently in the tests directory.

To run the tests:

  1. Update ./java/examples/com/rdio/simple/examples/ConsumerCredentials.java to include your API keys.
  2. Run the following:
cd java
ant compile
cd ../tests
javac -cp ../java/classes Tester.java
./run-tests.py

Notes

The test suite relies on the ruby-1.9 command to run the ruby test suite for version 1.9. If your default Ruby is 1.9, or you use a different command to access 1.9 (i.e. using rvm), then you'll need to comment out https://github.com/rdio/rdio-simple/blob/master/tests/run-tests.py#L24

rdio-simple's People

Contributors

creatorrr avatar dasevilla avatar ianloic avatar mjackson avatar mmontag avatar xyshal avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rdio-simple's Issues

Developer Inactive

is the ruby client up to date? keep getting a 'developer inactive' message.

Unicode issue in om.py

I tried to use the API with a unicode string, but om.py assumes all strings are ASCII.

Line 92 in om.py:

 def escape(s): return urllib.quote(unicode(s).encode('utf-8'), safe='~')

The unicode() constructor defaults to 'ascii' encoding.

Changing the function to:

def escape(s):
  try:
      s = unicode(s)
  except UnicodeDecodeError:
      s = unicode(s, 'utf-8')
  return urllib.quote(s.encode('utf-8'), safe='~')

works nicely.

Thanks!

oauth2 support?

Hello,

Now that Rdio has moved to oauth2, is there a timeline for when these reference libraries will be upgraded as well?

Thanks!

rdio-simple python fails with unicode strings

Hello,

I am trying to call the api with a string containing unicde, but I always get an error, doesn't matter if I encode it with encode or not.

The following code can be used to reproduce the issue:

# -*- coding: utf-8 -*-

from __future__ import unicode_literals

import sys,os.path
import json
import time
import traceback

from rdio import Rdio

try:
    from urllib.error import HTTPError
except ImportError:
    from urllib2 import HTTPError

rdio = Rdio((RDIO_CONSUMER_KEY, RDIO_CONSUMER_SECRET), AUTH_TOKEN)

name = "Röyksopp"

search = rdio.call('search', {'query': name, 'types': 'Album'})

print search

This throws:

Traceback (most recent call last):
  File "issue.py", line 26, in <module>
    search = rdio.call('search', {'query': name, 'types': 'Album'})
  File "/home/simao/spotify-export/rdio.py", line 77, in call
    return json.loads(self.__signed_post('http://api.rdio.com/1/', params))
  File "/home/simao/spotify-export/rdio.py", line 45, in __signed_post
    req = Request(url, urlencode(params).encode('utf-8'),
  File "/usr/lib/python2.7/urllib.py", line 1332, in urlencode
    v = quote_plus(str(v))
UnicodeEncodeError: 'ascii' codec can't encode character u'\xf6' in position 1: ordinal not in range(128)

Py3k support

Any plan?

I'll be happy to send a PR adding Py3k support, if you don't mind dropping Python 2.5 support (although I doubt the code would run in Python2.5)

Add Support for Ruby 1.9.3

I know you say right up front that only Ruby 1.8 has been tested. I thought it was worth noting that that rdio doesn't work at all in 1.9.3 because there is no 'new' method, which kind of prevents any activity at all. Here's an irb example:

1.9.3p385 :001 > require 'rdio'
=> true 
1.9.3p385 :002 > rdio = Rdio.new
NoMethodError: undefined method `new' for Rdio:Module
    from (irb):2
from /home/carleton/.rvm/rubies/ruby-1.9.3-p385/bin/irb:16:in `<main>'

how can i tell if my token's bad ?

as i was writing this question i was playing around and figured out some answers ... hooray ! still have questions .

from https://github.com/rdio/rdio-simple/blob/master/python/rdio.py#L73 can i just save_token=rdio.token . then from http://www.rdio.com/developers/docs/libraries/simple/ it seems like i should totally be able to do this:

rdio = Rdio(("consumerkey", "consumersecret"), save_token)

and that works! sweet! but then i changed the token to see what the issues would be if i had the wrong token or some issue, no error got raised . and then when i tried:

(Pdb) !import code; code.interact(local=vars())
Python 2.7.9 (default, Feb 10 2015, 03:28:08)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.56)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> self.rdio.call("currentUser", '')
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/Users/timball/Documents/grimeys/rdio.py", line 88, in call
    return json.loads(self.__signed_post('http://api.rdio.com/1/', params))
  File "/Users/timball/Documents/grimeys/rdio.py", line 58, in __signed_post
    res = urlopen(req)
  File "/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 154, in urlopen
    return opener.open(url, data, timeout)
  File "/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 437, in open
    response = meth(req, response)
  File "/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 550, in http_response
    'http', request, response, code, msg, hdrs)
  File "/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 475, in error
    return self._call_chain(*args)
  File "/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 409, in _call_chain
    result = func(*args)
  File "/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 558, in http_error_default
    raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
HTTPError: HTTP Error 403: Forbidden
>>> self.rdio
<rdio.Rdio instance at 0x108b2bb90>

do i just have to wrap in a try, except wrapper and test for the 503 from the server ? or am i missing something ? probably missing something .

so in summary what does the Rdio() constructor return if the token is bad? or expired? or something else? shouldn't it raise an exception ? or want to raise an exception ? pretending to raise an exception . i guess i'm good w/ pretending , but it seems sad pants that i'll have to immediately make a call to hope for failure .

--timball

Fix project description

In the description, it says the libraries are for PHP, Python, and Ruby, but this now extends much beyond those 3 languages.

Token = NULL in Rdio constructor

More of a question than an issue...why is token set to null in the Rdio constructor? (rdio.php). Why not use the client secret token associated with an app?

401 invalid signature response when any params aren't basic alphanumeric chars in ruby wrapper

I had to hack the om.rb file and change the percent_encode method to the following:

def percent_encode(s)
chars = s.chars.map do |c|
if ((c >= '0' and c <= '9') or
(c >= 'A' and c <= 'Z') or
(c >= 'a' and c <= 'z') or
c == '-' or c == '.' or c == '_' or c == '~')
c
elsif(c == ' ') # added until rdio fixes their stuff
'%%%02X' % c.unpack('c')
else
CGI.escape(c)
end
end
chars.join
end

I don't get why you aren't using standard url encoding anyway. Am I missing something? Thanks!

Calling `setAvailableOffline'... (ruby) gives an error

I'm using the Ruby implementation of the rdio-simple library, and am having trouble getting the setAvailableOffline method to work correctly. The server logs keep returning this error:

.../rdio-simple/om.rb:109:in `sort!': comparison of Array with Array failed (ArgumentError)
from .../rdio-simple/om.rb:109:in `om'
from .../rdio-simple/rdio.rb:69:in `signed_post'
from .../rdio-simple/rdio.rb:63:in `call'
from command-line.rb:59:in `<main>'

I've tried several implementations, including:

rdio.call('setAvailableOffline', {:keys => 'THIS_IS_MY_TRACK_KEY', :offline => true})
rdio.call('setAvailableOffline', :keys => 'THIS_IS_MY_TRACK_KEY', :offline => true)
rdio.call('setAvailableOffline', 'THIS_IS_MY_TRACK_KEY', true) # i figured this one wouldn't work, but tried it nonetheless

where THIS_IS_MY_TRACK_KEY is a string corresponding to a specific track's key. In the end, I'm going to iterate over a series of tracks, and make it a comma-separated value like the Docs say, but for now, I just want to get it functional for one specific item.

I haven't adjusted om.rb at all, and am getting the error mentioned above.

Any ideas as to why this isn't going through? I've tried it on the web client and the CLI - both are returning the same errors.

Thanks!

Turn into an npm module

This would be lovely as an npm module. Perhaps submodule the node directory into its own repository, and add a package.json?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.