简体   繁体   中英

making calls using Twilio API from JavaScript

is there a way to make calls/send messages using twilioAPI only with JavaScript ? The twilio documentation clearly explains how to make calls using Nodejs,Python, php,ruby ...but can it be done with JavaScript alone?

The below nodeJS code worked for me when i ran it on my PC.but how can i make it run in a website ?? I have done some research to find Heroku to host nodejs apps.if so,How to invoke this code hosted in heroku from my JavaScript?

var accountSid = 'AC5ef8732a3c49700934481addd5ce1659';

var authToken = "{{ auth_token }}";

var client = require('twilio')(accountSid, authToken);

client.calls.create({

url: "http://demo.twilio.com/docs/voice.xml",

to: "+14155551212",

sendDigits: "1234#",

from: "+18668675309",

method: "GET"

}, function(err, call) {

process.stdout.write(call.sid);

});

Twilio evangelist here.

Using the Twilio API from JavaScript is not recommended because it would require you to put your API credentials into the web page exposing them for all the world to see.

You can use some JavaScript in your webpage to make an async request to your node app on the server and have it interact with the API, or you can embed the aility to make a call directly from your web page using the Twilio Client JavaScript SDK .

Hope that helps.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM