Danish Habib

Danish Habib

  • NA
  • 694
  • 244k

Twilio is not making call

Jun 9 2015 12:21 AM
I am using that markup
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="twilio.WebForm1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<%-- <asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click"
style="height: 26px" />--%>
<div>
<asp:BulletedList ID="varDisplay" runat="server" BulletStyle="NotSet">
</asp:BulletedList>
</div>
<div>
<p>Fill in all fields and click <b>Make this call</b>.</p>
<div>
To:<br /><asp:TextBox ID="toNumber" runat="server" /><br /><br />
Message:<br /><asp:TextBox ID="message" runat="server" /><br /><br />
<asp:Button ID="callpage" runat="server" Text="Make this call"
onclick="callpage_Click" />
</div>
</div>
</div>
</form>
</body>
</html>
my code behind is that
protected void callpage_Click(object sender, EventArgs e)
{
// Call porcessing happens here.
// Use your account SID and authentication token instead of
// the placeholders shown here.
string accountSID = "myid";
string authToken = "mytoken";
// Instantiate an instance of the Twilio client.
TwilioRestClient client;
client = new TwilioRestClient(accountSID, authToken);
// Retrieve the account, used later to retrieve the
Twilio.Account account = client.GetAccount();
string APIversuion = client.ApiVersion;
string TwilioBaseURL = client.BaseUrl;
this.varDisplay.Items.Clear();
if (this.toNumber.Text == "" || this.message.Text == "")
{
this.varDisplay.Items.Add(
"You must enter a phone number and a message.");
}
else
{
// Retrieve the values entered by the user.
string to = this.toNumber.Text;
string myMessage = this.message.Text;
// Create a URL using the Twilio message and the user-entered
// text. You must replace spaces in the user's text with '%20'
// to make the text suitable for a URL.
String Url = "https://demo.twilio.com/welcome/voice/?Message%5B0%5D="
+ myMessage.Replace(" ", "%20");
// Display the endpoint, API version, and the URL for the message.
this.varDisplay.Items.Add("Using Twilio endpoint "
+ TwilioBaseURL);
this.varDisplay.Items.Add("Twilioclient API Version is "
+ APIversuion);
this.varDisplay.Items.Add("The URL is " + Url);
// Instantiate the call options that are passed
// to the outbound call.
CallOptions options = new CallOptions();
// Set the call From, To, and URL values.
options.From = "+15016536555";
options.To = to;
options.Url = Url;
// Place the call.
var call = client.InitiateOutboundCall(options);
this.varDisplay.Items.Add("Call status: " + call.Status);
}
Myid and mytoken is replaced by origional values but i am not getting call ?call.status shows null

Answers (4)