Skip to content

Instantly share code, notes, and snippets.

@chenghaoc
Created June 27, 2016 02:46
Show Gist options
  • Save chenghaoc/74f99ee50eb714e60a6dd60dfa399d44 to your computer and use it in GitHub Desktop.
Save chenghaoc/74f99ee50eb714e60a6dd60dfa399d44 to your computer and use it in GitHub Desktop.
Ringcentral-web-phone with CommonJS module bundler
var RingCentral = require('ringcentral')
var WebPhone = require('ringcentral-web-phone')
var appKey = '...';
var appSecret = '...';
var appName = '...';
var appVersion = '...';
var sdk = new RingCentral({
appKey: appKey,
appSecret: appSecret,
appName: appName,
appVersion: appVersion,
server: RingCentral.server.production // or .sandbox
});
var platform = sdk.platform();
platform
.login({
username: '...',
password: '...'
})
.then(function(loginResponse) {
return platform
.post('/client-info/sip-provision', {
sipInfo: [{transport: 'WSS'}]
})
.then(function(res) {
return new WebPhone(res.json(), { // optional
appKey: appKey,
appName: appName,
appVersion: appVersion,
uuid: loginResponse.json().endpoint_id,
logLevel: 1, // error 0, warn 1, log: 2, debug: 3
audioHelper: {
enabled: true, // enables audio feedback when web phone is ringing or making a call
incoming: 'path-to-audio/incoming.ogg', // path to audio file for incoming call
outgoing: 'path-to-audio/outgoing.ogg' // path to aduotfile for outgoing call
}
});
});
})
.then(function(webPhone){
// YOUR CODE HERE
})
.catch(function(e){
console.error(e.stack);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment