Twilio API - How to hang up all active calls using C#?
I'm looking for help in hanging up all calls regardless of status, using C# and the Twilio API. Something like a no nonsense 'Kill Switch'.
I saw this code written in python and wondered if anyone had any examples in C# I could look at?
from twilio.rest import TwilioRestClient
from twilio.rest.resources import Call
ACCOUNT_SID = "YOUR_ACCOUNT_SID"
AUTH_TOKEN = "YOUR_AUTH_TOKEN"
client = TwilioRestClient(ACCOUNT_SID, AUTH_TOKEN)
calls = client.calls.list(status=Call.IN_PROGRESS)
for c in calls:
c.hangup()
c# .net twilio twilio-api
add a comment |
I'm looking for help in hanging up all calls regardless of status, using C# and the Twilio API. Something like a no nonsense 'Kill Switch'.
I saw this code written in python and wondered if anyone had any examples in C# I could look at?
from twilio.rest import TwilioRestClient
from twilio.rest.resources import Call
ACCOUNT_SID = "YOUR_ACCOUNT_SID"
AUTH_TOKEN = "YOUR_AUTH_TOKEN"
client = TwilioRestClient(ACCOUNT_SID, AUTH_TOKEN)
calls = client.calls.list(status=Call.IN_PROGRESS)
for c in calls:
c.hangup()
c# .net twilio twilio-api
add a comment |
I'm looking for help in hanging up all calls regardless of status, using C# and the Twilio API. Something like a no nonsense 'Kill Switch'.
I saw this code written in python and wondered if anyone had any examples in C# I could look at?
from twilio.rest import TwilioRestClient
from twilio.rest.resources import Call
ACCOUNT_SID = "YOUR_ACCOUNT_SID"
AUTH_TOKEN = "YOUR_AUTH_TOKEN"
client = TwilioRestClient(ACCOUNT_SID, AUTH_TOKEN)
calls = client.calls.list(status=Call.IN_PROGRESS)
for c in calls:
c.hangup()
c# .net twilio twilio-api
I'm looking for help in hanging up all calls regardless of status, using C# and the Twilio API. Something like a no nonsense 'Kill Switch'.
I saw this code written in python and wondered if anyone had any examples in C# I could look at?
from twilio.rest import TwilioRestClient
from twilio.rest.resources import Call
ACCOUNT_SID = "YOUR_ACCOUNT_SID"
AUTH_TOKEN = "YOUR_AUTH_TOKEN"
client = TwilioRestClient(ACCOUNT_SID, AUTH_TOKEN)
calls = client.calls.list(status=Call.IN_PROGRESS)
for c in calls:
c.hangup()
c# .net twilio twilio-api
c# .net twilio twilio-api
asked Nov 14 '18 at 20:37
JamesJames
63
63
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
You can do something like this:
// Install the C# / .NET helper library from twilio.com/docs/csharp/install
using System;
using Twilio;
using Twilio.Rest.Api.V2010.Account;
class Program
{
static void Main(string args)
{
// Find your Account Sid and Token at twilio.com/console
const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
const string authToken = "your_auth_token";
TwilioClient.Init(accountSid, authToken);
var call = CallResource.Update(
status: CallResource.UpdateStatusEnum.Completed,
pathSid: "CAe1644a7eed5088b159577c5802d8be38"
);
Console.WriteLine(call.To);
}
}
You can wrap the CallResource.Update(...)
method in a for loop and pass a list of active calls as a parameter.
You can find more information here: https://www.twilio.com/docs/voice/tutorials/how-to-modify-calls-in-progress-in-csharp#hanging-up-a-call-in-progress
Thanks Tim. Yes, I had the API reference guide up. I noted though, that in some cases, other languages like python seem to have more available options than C#. It led me to wonder if there was a C# equivalent of the .hangup call. I'm new to C# (like this week) and I don't have a great deal of experience in coding anyway.
– James
Nov 15 '18 at 9:13
add a comment |
I came up with this. Not elegant in the least, but it works:
private void KillSwitch(string accountSid, string authToken)
{
TwilioClient.Init(accountSid, authToken);
var callsInProgress = CallResource.Read(status: CallResource.StatusEnum.InProgress);
var callsQueued = CallResource.Read(status: CallResource.StatusEnum.Queued);
var callsRinging = CallResource.Read(status: CallResource.StatusEnum.Ringing);
foreach (var call in callsQueued)
{
CallResource.Update(status: CallResource.UpdateStatusEnum.Completed, pathSid: call.Sid);
}
foreach (var call in callsInProgress)
{
CallResource.Update(status: CallResource.UpdateStatusEnum.Completed, pathSid: call.Sid);
}
foreach (var call in callsRinging)
{
CallResource.Update(status: CallResource.UpdateStatusEnum.Completed, pathSid: call.Sid);
}
}
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53308368%2ftwilio-api-how-to-hang-up-all-active-calls-using-c%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
You can do something like this:
// Install the C# / .NET helper library from twilio.com/docs/csharp/install
using System;
using Twilio;
using Twilio.Rest.Api.V2010.Account;
class Program
{
static void Main(string args)
{
// Find your Account Sid and Token at twilio.com/console
const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
const string authToken = "your_auth_token";
TwilioClient.Init(accountSid, authToken);
var call = CallResource.Update(
status: CallResource.UpdateStatusEnum.Completed,
pathSid: "CAe1644a7eed5088b159577c5802d8be38"
);
Console.WriteLine(call.To);
}
}
You can wrap the CallResource.Update(...)
method in a for loop and pass a list of active calls as a parameter.
You can find more information here: https://www.twilio.com/docs/voice/tutorials/how-to-modify-calls-in-progress-in-csharp#hanging-up-a-call-in-progress
Thanks Tim. Yes, I had the API reference guide up. I noted though, that in some cases, other languages like python seem to have more available options than C#. It led me to wonder if there was a C# equivalent of the .hangup call. I'm new to C# (like this week) and I don't have a great deal of experience in coding anyway.
– James
Nov 15 '18 at 9:13
add a comment |
You can do something like this:
// Install the C# / .NET helper library from twilio.com/docs/csharp/install
using System;
using Twilio;
using Twilio.Rest.Api.V2010.Account;
class Program
{
static void Main(string args)
{
// Find your Account Sid and Token at twilio.com/console
const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
const string authToken = "your_auth_token";
TwilioClient.Init(accountSid, authToken);
var call = CallResource.Update(
status: CallResource.UpdateStatusEnum.Completed,
pathSid: "CAe1644a7eed5088b159577c5802d8be38"
);
Console.WriteLine(call.To);
}
}
You can wrap the CallResource.Update(...)
method in a for loop and pass a list of active calls as a parameter.
You can find more information here: https://www.twilio.com/docs/voice/tutorials/how-to-modify-calls-in-progress-in-csharp#hanging-up-a-call-in-progress
Thanks Tim. Yes, I had the API reference guide up. I noted though, that in some cases, other languages like python seem to have more available options than C#. It led me to wonder if there was a C# equivalent of the .hangup call. I'm new to C# (like this week) and I don't have a great deal of experience in coding anyway.
– James
Nov 15 '18 at 9:13
add a comment |
You can do something like this:
// Install the C# / .NET helper library from twilio.com/docs/csharp/install
using System;
using Twilio;
using Twilio.Rest.Api.V2010.Account;
class Program
{
static void Main(string args)
{
// Find your Account Sid and Token at twilio.com/console
const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
const string authToken = "your_auth_token";
TwilioClient.Init(accountSid, authToken);
var call = CallResource.Update(
status: CallResource.UpdateStatusEnum.Completed,
pathSid: "CAe1644a7eed5088b159577c5802d8be38"
);
Console.WriteLine(call.To);
}
}
You can wrap the CallResource.Update(...)
method in a for loop and pass a list of active calls as a parameter.
You can find more information here: https://www.twilio.com/docs/voice/tutorials/how-to-modify-calls-in-progress-in-csharp#hanging-up-a-call-in-progress
You can do something like this:
// Install the C# / .NET helper library from twilio.com/docs/csharp/install
using System;
using Twilio;
using Twilio.Rest.Api.V2010.Account;
class Program
{
static void Main(string args)
{
// Find your Account Sid and Token at twilio.com/console
const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
const string authToken = "your_auth_token";
TwilioClient.Init(accountSid, authToken);
var call = CallResource.Update(
status: CallResource.UpdateStatusEnum.Completed,
pathSid: "CAe1644a7eed5088b159577c5802d8be38"
);
Console.WriteLine(call.To);
}
}
You can wrap the CallResource.Update(...)
method in a for loop and pass a list of active calls as a parameter.
You can find more information here: https://www.twilio.com/docs/voice/tutorials/how-to-modify-calls-in-progress-in-csharp#hanging-up-a-call-in-progress
answered Nov 14 '18 at 22:32
Tim AlonsoTim Alonso
367
367
Thanks Tim. Yes, I had the API reference guide up. I noted though, that in some cases, other languages like python seem to have more available options than C#. It led me to wonder if there was a C# equivalent of the .hangup call. I'm new to C# (like this week) and I don't have a great deal of experience in coding anyway.
– James
Nov 15 '18 at 9:13
add a comment |
Thanks Tim. Yes, I had the API reference guide up. I noted though, that in some cases, other languages like python seem to have more available options than C#. It led me to wonder if there was a C# equivalent of the .hangup call. I'm new to C# (like this week) and I don't have a great deal of experience in coding anyway.
– James
Nov 15 '18 at 9:13
Thanks Tim. Yes, I had the API reference guide up. I noted though, that in some cases, other languages like python seem to have more available options than C#. It led me to wonder if there was a C# equivalent of the .hangup call. I'm new to C# (like this week) and I don't have a great deal of experience in coding anyway.
– James
Nov 15 '18 at 9:13
Thanks Tim. Yes, I had the API reference guide up. I noted though, that in some cases, other languages like python seem to have more available options than C#. It led me to wonder if there was a C# equivalent of the .hangup call. I'm new to C# (like this week) and I don't have a great deal of experience in coding anyway.
– James
Nov 15 '18 at 9:13
add a comment |
I came up with this. Not elegant in the least, but it works:
private void KillSwitch(string accountSid, string authToken)
{
TwilioClient.Init(accountSid, authToken);
var callsInProgress = CallResource.Read(status: CallResource.StatusEnum.InProgress);
var callsQueued = CallResource.Read(status: CallResource.StatusEnum.Queued);
var callsRinging = CallResource.Read(status: CallResource.StatusEnum.Ringing);
foreach (var call in callsQueued)
{
CallResource.Update(status: CallResource.UpdateStatusEnum.Completed, pathSid: call.Sid);
}
foreach (var call in callsInProgress)
{
CallResource.Update(status: CallResource.UpdateStatusEnum.Completed, pathSid: call.Sid);
}
foreach (var call in callsRinging)
{
CallResource.Update(status: CallResource.UpdateStatusEnum.Completed, pathSid: call.Sid);
}
}
add a comment |
I came up with this. Not elegant in the least, but it works:
private void KillSwitch(string accountSid, string authToken)
{
TwilioClient.Init(accountSid, authToken);
var callsInProgress = CallResource.Read(status: CallResource.StatusEnum.InProgress);
var callsQueued = CallResource.Read(status: CallResource.StatusEnum.Queued);
var callsRinging = CallResource.Read(status: CallResource.StatusEnum.Ringing);
foreach (var call in callsQueued)
{
CallResource.Update(status: CallResource.UpdateStatusEnum.Completed, pathSid: call.Sid);
}
foreach (var call in callsInProgress)
{
CallResource.Update(status: CallResource.UpdateStatusEnum.Completed, pathSid: call.Sid);
}
foreach (var call in callsRinging)
{
CallResource.Update(status: CallResource.UpdateStatusEnum.Completed, pathSid: call.Sid);
}
}
add a comment |
I came up with this. Not elegant in the least, but it works:
private void KillSwitch(string accountSid, string authToken)
{
TwilioClient.Init(accountSid, authToken);
var callsInProgress = CallResource.Read(status: CallResource.StatusEnum.InProgress);
var callsQueued = CallResource.Read(status: CallResource.StatusEnum.Queued);
var callsRinging = CallResource.Read(status: CallResource.StatusEnum.Ringing);
foreach (var call in callsQueued)
{
CallResource.Update(status: CallResource.UpdateStatusEnum.Completed, pathSid: call.Sid);
}
foreach (var call in callsInProgress)
{
CallResource.Update(status: CallResource.UpdateStatusEnum.Completed, pathSid: call.Sid);
}
foreach (var call in callsRinging)
{
CallResource.Update(status: CallResource.UpdateStatusEnum.Completed, pathSid: call.Sid);
}
}
I came up with this. Not elegant in the least, but it works:
private void KillSwitch(string accountSid, string authToken)
{
TwilioClient.Init(accountSid, authToken);
var callsInProgress = CallResource.Read(status: CallResource.StatusEnum.InProgress);
var callsQueued = CallResource.Read(status: CallResource.StatusEnum.Queued);
var callsRinging = CallResource.Read(status: CallResource.StatusEnum.Ringing);
foreach (var call in callsQueued)
{
CallResource.Update(status: CallResource.UpdateStatusEnum.Completed, pathSid: call.Sid);
}
foreach (var call in callsInProgress)
{
CallResource.Update(status: CallResource.UpdateStatusEnum.Completed, pathSid: call.Sid);
}
foreach (var call in callsRinging)
{
CallResource.Update(status: CallResource.UpdateStatusEnum.Completed, pathSid: call.Sid);
}
}
answered Nov 15 '18 at 9:16
JamesJames
63
63
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53308368%2ftwilio-api-how-to-hang-up-all-active-calls-using-c%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown