-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathapi.js
45 lines (45 loc) · 1.22 KB
/
api.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
module.exports = function(app, rdio){
app.get ('/api/rdio/topcharts', function(req, res, params) {
rdio.api(
req.session.oauth_access_token,
req.session.oauth_access_token_secret,
{
method: 'getTopCharts',
type: 'Track',
count: 10
}, function(err, data, response) {
var tracks = JSON.parse(data);
res.contentType('application/json');
res.send(tracks);
});
});
app.get('/api/rdio/get', function(req, res, params) {
var keys = req.query.keys;
rdio.api(
req.session.oauth_access_token,
req.session.oauth_access_token_secret,
{
method: 'get',
keys: keys
}, function(err, data, response) {
res.contentType('application/json');
res.send(JSON.parse(data));
});
});
app.get('/api/rdio/search', function(req, res, params) {
var term = req.query.q;
rdio.api(
req.session.oauth_access_token,
req.session.oauth_access_token_secret,
{
method: 'search',
query: term,
types: 'track',
count: 10
}, function(err, data, response) {
res.contentType('application/json');
res.send(JSON.parse(data));
}
);
});
};