Пример #1
0
        public static List<TwilioNumber> GetUnusedNumberList()
        {
            var available = new List<TwilioNumber>();

            var twilio = new TwilioRestClient(GetSid(), GetToken());
            var numbers = twilio.ListIncomingPhoneNumbers();

            var used = (from e in DbUtil.Db.SMSNumbers
                        select e).ToList();

            for (var iX = numbers.IncomingPhoneNumbers.Count() - 1; iX > -1; iX--)
            {
                if (used.Any(n => n.Number == numbers.IncomingPhoneNumbers[iX].PhoneNumber))
                    numbers.IncomingPhoneNumbers.RemoveAt(iX);
            }

            foreach (var item in numbers.IncomingPhoneNumbers)
            {
                var newNum = new TwilioNumber();
                newNum.Name = item.FriendlyName;
                newNum.Number = item.PhoneNumber;

                available.Add(newNum);
            }

            return available;
        }
Пример #2
0
        public static List<IncomingPhoneNumber> GetNumberList()
        {
            var twilio = new TwilioRestClient(GetSid(), GetToken());
            var numbers = twilio.ListIncomingPhoneNumbers();

            return numbers.IncomingPhoneNumbers;
        }
Пример #3
0
        public SmsSender(string accountSid, string authToken, string fromPhoneNumber = null)
        {
            this.client = new TwilioRestClient(accountSid, authToken);

            if (fromPhoneNumber == null)
            {
                fromPhoneNumber = client.ListIncomingPhoneNumbers().IncomingPhoneNumbers.Select(a => a.PhoneNumber).First();
            }

            this.fromPhoneNumber = fromPhoneNumber;
        }
    static void Main(string[] args)
    {
        // Find your Account Sid and Auth Token at twilio.com/user/account
        string AccountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        string AuthToken = "your_auth_token";
        var twilio = new TwilioRestClient(AccountSid, AuthToken);

        var numbers = twilio.ListIncomingPhoneNumbers("867", null, null, null);

        foreach (var number in numbers.IncomingPhoneNumbers)
        {
          Console.WriteLine(number.VoiceUrl);
        }
    }
        protected void btn_Click(object sender, EventArgs e)
        {
            string accountSid = "AC49ecef1b877e244ea13ada1b5fe92b85";
            //string applicationsid = "AP5556f6cd1af5cfa5317acae7a49eeb5c";
            string sid = "CA748c6019014ca0ac151908a81299f927";
            string authToken = "4eeeaf7ed6459dcd02ec7888149d5ea1";
            string recordingSid = "RE5dabfb2da314b39cd87dc151bf669e78";
               DateTime datecreated=DateTime.Now;
            TwilioRestClient client;
            client = new TwilioRestClient(accountSid, authToken);
            string APIversuion = client.ApiVersion;
            string TwilioBaseURL = client.BaseUrl;

            Account account = client.GetAccount(accountSid);
            client.GetRecording(recordingSid);
            client.GetRecordingText(recordingSid);
            client.ListRecordings(sid, datecreated, 1, 2);
            client.ListQueues();
            client.ListIncomingPhoneNumbers();
            this.varDisplay.Items.Clear();
            if (this.txtcall.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.txtcall.Text;
                string myMessage = this.message.Text;
                //string Url = "http://demo.twilio.com/Welcome/Call/";
            String Url = "http://twimlets.com/message?Message%5B0%5D=" + myMessage.Replace(" ", "%20");
                // Diplay the enpoint, API version, and the URL for the message.
                this.varDisplay.Items.Add("Using Tilio 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 into a hash map. // This sample uses the sandbox number provided by Twilio // to make the call.
                options.From = "+14242165015";
                options.To = to;
                options.Url = Url; // Place the call.
                options.Record = true;
                var call = client.InitiateOutboundCall(options);
                this.varDisplay.Items.Add("Call status: " + call.Status); }
        }
 public static IncomingPhoneNumberResult GetPhoneNumbers(Account Acnt)
 {
     TwilioRestClient acntInfo = new TwilioRestClient(Acnt.Sid, Acnt.AuthToken);
     IncomingPhoneNumberResult phoneNumbers = acntInfo.ListIncomingPhoneNumbers();
     return phoneNumbers;
 }
Пример #7
0
        protected void ContactBarber_Click(object sender, EventArgs e)
        {
            BindDataList();

            string sql = "SELECT idMembership FROM member WHERE idMember = " + Request.QueryString["id"];
            DataTable dt = Worker.SqlTransaction(sql, connect_string);
            if (dt.Rows.Count > 0)
            {
                if ((dt.Rows[0]["idMembership"].ToString() == "2") || (dt.Rows[0]["idMembership"].ToString() == "1"))
                {
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "Alert", "AddResource('440','415');", true);
                }
                else
                {

                    phoneno = (string)Session["phoneno"];
                    string accountSid = "AC49ecef1b877e244ea13ada1b5fe92b85";
                    //string applicationsid = "AP5556f6cd1af5cfa5317acae7a49eeb5c";
                    string sid = "CA748c6019014ca0ac151908a81299f927";
                    string authToken = "4eeeaf7ed6459dcd02ec7888149d5ea1";
                    string recordingSid = "RE5dabfb2da314b39cd87dc151bf669e78";
                    DateTime datecreated = DateTime.Now;
                    TwilioRestClient client;
                    client = new TwilioRestClient(accountSid, authToken);
                    string APIversuion = client.ApiVersion;
                    string TwilioBaseURL = client.BaseUrl;

                    Account account = client.GetAccount(accountSid);
                    client.GetRecording(recordingSid);
                    client.GetRecordingText(recordingSid);
                    client.ListRecordings(sid, datecreated, 1, 2);
                    client.ListQueues();
                    client.ListIncomingPhoneNumbers();
                    //string Url = "http://demo.twilio.com/Welcome/Call/";
                    String Url = "http://twimlets.com/message";
                    CallOptions options = new CallOptions(); // Set the call From, To, and URL values into a hash map. // This sample uses the sandbox number provided by Twilio // to make the call.
                    options.From = "+14242165015";
                    options.To = phoneno;
                    options.Url = Url; // Place the call.
                    options.Record = true;

                    var call = client.InitiateOutboundCall(options);

                    Session.Remove("phoneno");
                }

            }
        }