コード例 #1
0
        public ActionResult Index(string query)
        {
            var client = new TwilioRestClient(Credentials.AccountSid, Credentials.AuthToken);
            var result = client.ListAvailableLocalPhoneNumbers("US", new AvailablePhoneNumberListRequest() { AreaCode = query });

            if (result.RestException != null)
                return Json(null);

            return Json(result.AvailablePhoneNumbers.Take(7));
        }
コード例 #2
0
    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 options = new AvailablePhoneNumberListRequest();
        options.AreaCode = "510";

        var result = twilio.ListAvailableLocalPhoneNumbers("US", options);

        // Purchase the first number on the list
        var availableNumber = result.AvailablePhoneNumbers[0];
        var purchaseOptions = new PhoneNumberOptions();
        purchaseOptions.PhoneNumber = availableNumber.PhoneNumber;

        var number = twilio.AddIncomingPhoneNumber(purchaseOptions);
        Console.WriteLine(number.Sid);
    }
コード例 #3
0
    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 options = new AvailablePhoneNumberListRequest();
        options.NearLatLong = "37.840699,-122.461853";
        options.Distance = 50;
        options.Contains = "555";
        options.InRegion = "CA";

        var result = twilio.ListAvailableLocalPhoneNumbers("US", options);

        // Purchase the first number on the list
        var availableNumber = result.AvailablePhoneNumbers[0];
        var purchaseOptions = new PhoneNumberOptions();
        purchaseOptions.PhoneNumber = availableNumber.PhoneNumber;

        var number = twilio.AddIncomingPhoneNumber(purchaseOptions);
        Console.WriteLine(number.Sid);
    }