Skip to content

Instantly share code, notes, and snippets.

@voipnorm
Created January 9, 2017 18:24
var request = require('request');
var logger = require('log4js');
logger.configure({
appenders: [
{type:'console'},
{type: 'file', filename: 'logs/application.log', catergory:'application'}
],
replaceConsole: true
});
exports.newMessage = function sparkMessage(sparkToken, text, to) {
request({
url: 'https://api.ciscospark.com/v1/messages',
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer ' + sparkToken
},
body:
JSON.stringify({'toPersonEmail': to,
'markdown': text})
}, function (error, response, body) {
if (error) {
console.log(error);
} else {
console.log(response.statusCode, body);
}
});
};
exports.getSpMeStatus = function sparkID(sparkToken, callback){
{
request({
url: 'https://api.ciscospark.com/v1/people/me',
method: 'GET',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer ' + sparkToken
},
}, function (error, response, body) {
if (error) {
console.log(error);
} else {
console.log(response.statusCode, body);
body = JSON.parse(body);
var status = body.status;
callback(status);
}
});
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment