I am trying to store a session id in a variable that I need in order to make other calls to the external API I am using. I am running it all on the server side, sorry if I messed any of this up, I am new to stack overflow and API use in general.
Here is the code that establishes the connection.
if (Meteor.isServer) {
var devId = "XXXX";
var authKey = "XXXXXXXXXXXXXXXXXXXXXXX";
var utcTime = moment.utc().format("YYYYMMDDHHmmss");
var signature = CryptoJS.MD5(devId + 'createsession' + authKey + utcTime).toString()
HTTP.call('GET', 'http://api.smitame.com/smiteapi.svc/createsessionJson/' + devId + '/' + signature + '/' + utcTime, {
}, function(error, response){
if ( error ) {
console.log( error );
} else {
console.log( response );
}
});
}
Here is the data displayed back into my terminal, how can I grab that session_id?
data:
I20160108-22:23:29.324(-7)? { ret_msg: 'Approved',
I20160108-22:23:29.324(-7)? session_id: '270E9528F59E40DD88F504BE63A9DC6E',
I20160108-22:23:29.325(-7)? timestamp: '1/9/2016 5:23:29 AM' } }
Okay, if anyone ever needs this for something, I figured out what I needed for this. Here is the correct version for what I was trying to do.
HTTP.call('GET', 'http://api.smitame.com/smiteapi.svc/createsessionJson/' + devId + '/' + signature + '/' + utcTime, {
}, function(error, response){
if ( error ) {
console.log( error );
} else {
console.log( response );
var sessionId = response.data.session_id;
}
});
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.