Created
February 20, 2020 18:23
-
-
Save recursivecodes/65f149faa1b232e6236bf50103285e36 to your computer and use it in GitHub Desktop.
ring-central-sms.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const SDK = require('@ringcentral/sdk').SDK | |
RECIPIENT = '<ENTER PHONE NUMBER>' | |
RINGCENTRAL_CLIENTID = '<ENTER CLIENT ID>' | |
RINGCENTRAL_CLIENTSECRET = '<ENTER CLIENT SECRET>' | |
RINGCENTRAL_SERVER = 'https://platform.devtest.ringcentral.com' | |
RINGCENTRAL_USERNAME = '<YOUR ACCOUNT PHONE NUMBER>' | |
RINGCENTRAL_PASSWORD = '<YOUR ACCOUNT PASSWORD>' | |
RINGCENTRAL_EXTENSION = '<YOUR EXTENSION, PROBABLY "101">' | |
var rcsdk = new SDK({ | |
server: RINGCENTRAL_SERVER, | |
clientId: RINGCENTRAL_CLIENTID, | |
clientSecret: RINGCENTRAL_CLIENTSECRET | |
}); | |
var platform = rcsdk.platform(); | |
platform.login({ | |
username: RINGCENTRAL_USERNAME, | |
password: RINGCENTRAL_PASSWORD, | |
extension: RINGCENTRAL_EXTENSION | |
}) | |
.then(function(resp) { | |
send_sms() | |
}); | |
function send_sms(){ | |
platform.post('/restapi/v1.0/account/~/extension/~/sms', { | |
from: {'phoneNumber': RINGCENTRAL_USERNAME}, | |
to: [{'phoneNumber': RECIPIENT}], | |
text: 'Hello World from JavaScript' | |
}) | |
.then(function (resp) { | |
console.log("SMS sent. Message status: " + resp.json().messageStatus) | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment