-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enable /catalogue/log endpoint support #73
Comments
You're right that this is n't currently supported. Your approach may work - give it a go. I'm having a look now to see if I can find a nicer solution for you. |
I'm afraid your approrach probably won't work because |
Ok, i've put a fix in to allow you to specify the HTTP verb when using var util= require('util');
var http = require('http');
var url = require('url');
var api = require('7digital-api');
var oauth = new api.OAuth();
var host = 'api.7digital.com';
var port = 80;
var signedUrl = oauth.sign(
'http://api.7digital.com/1.2/catalogue/log', {},
'POST');
console.log('URL: ', signedUrl);
var playLog = {
playLogItem: [ { /* ... */ } } ]
};
var postData = JSON.stringify(playLog);
var options = {
hostname: host,
port: port,
path: url.parse(signedUrl).path,
method: 'POST',
keepAlive: true,
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
}
};
var req = http.request(options, function (res) {
var responseBody = '';
// NB - We are not doing the full error handling and parsing here that
// the client would normally do for you
console.log('RES STATUS: ', res.statusCode);
console.log('RES HEADERS: ', JSON.stringify(res.headers));
res.setEncoding('utf-8');
res.on('data', function (chunk) {
responseBody += chunk;
});
res.on('end', function (chunk) {
if (chunk) {
responseBody += chunk;
}
console.log('PARSED RESPONSE');
console.log(
util.inspect(
JSON.parse(responseBody), { depth: null, colors: true }));
});
});
req.setHeader('Content-Length', postData.length);
req.on('error', function (e) {
// NB - I am not doing any error handling here
console.log('ERROR');
console.log(e);
});
console.log('REQ HEADERS: ');
console.log(req.headers);
console.log('REQ POST: ', postData);
req.write(postData);
req.end(); I need to do some work to specify an endpont's content type in the schema and then use it to support this properly. I'll create a separate issue to track that and let you know so you can clean up your code. Let me know if you have any issues. Thanks, |
No issues. Was able to refactor and integrate to what I have. Thank you so much! Should we close the issue now (since we've solved the lack of an API endpoint) or do we keep it open until it is part of the module and the API Schema? Have a great day! |
Great, glad you got it working. Let's keep this one open, I'll update here when we've added support for JSON/XML content-type POSTs. |
We need to have the
~/catalogue/log
endpoint to report radio streaming activity as this is a requirement of the labels.Right now when I look at the latest API Schema I do not see this method as part of the module.
Documentation on this particular logging method can be found here.
If this method just requires OAuth signing then can just take care of implementing it similar to the previews, streaming, and downloading tracks methods?
Here is what I mean as an example, using your README.md:
Let me know and thank you!
Daniel
The text was updated successfully, but these errors were encountered: