Exemple #1
0
    static void Main(string[] args)
    {
        // Find your Account Sid and Token at twilio.com/console
        // DANGER! This is insecure. See http://twil.io/secure
        const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string authToken  = "your_auth_token";

        TwilioClient.Init(accountSid, authToken);

        var addOns = new List <string> {
            "whitepages_pro_caller_id"
        };

        var phoneNumber = PhoneNumberResource.Fetch(
            addOns: addOns,
            pathPhoneNumber: new Twilio.Types.PhoneNumber("+16502530000")
            );

        Console.WriteLine(phoneNumber.Carrier);
    }
    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 type = new List <string> {
            "carrier"
        };

        var phoneNumber = PhoneNumberResource.Fetch(
            countryCode: "US",
            type: type,
            pathPhoneNumber: new Twilio.Types.PhoneNumber("+15108675310")
            );

        Console.WriteLine(phoneNumber.CallerName);
    }
        public void TestFetchRequest()
        {
            var twilioRestClient = Substitute.For <ITwilioRestClient>();
            var request          = new Request(
                HttpMethod.Get,
                Twilio.Rest.Domain.Lookups,
                "/v1/PhoneNumbers/+987654321",
                ""
                );

            twilioRestClient.Request(request).Throws(new ApiException("Server Error, no content"));

            try
            {
                PhoneNumberResource.Fetch(new Twilio.Types.PhoneNumber("+987654321"), client: twilioRestClient);
                Assert.Fail("Expected TwilioException to be thrown for 500");
            }
            catch (ApiException) {}
            twilioRestClient.Received().Request(request);
        }
Exemple #4
0
        public void TestFetchRequest()
        {
            var twilioRestClient = Substitute.For <ITwilioRestClient>();
            var request          = new Request(
                HttpMethod.Get,
                Twilio.Rest.Domain.Proxy,
                "/v1/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/PhoneNumbers/PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
                ""
                );

            twilioRestClient.Request(request).Throws(new ApiException("Server Error, no content"));

            try
            {
                PhoneNumberResource.Fetch("KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", client: twilioRestClient);
                Assert.Fail("Expected TwilioException to be thrown for 500");
            }
            catch (ApiException) {}
            twilioRestClient.Received().Request(request);
        }
Exemple #5
0
    static void Main(string[] args)
    {
        // Find your Account Sid and Token at twilio.com/console
        // DANGER! This is insecure. See http://twil.io/secure
        const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string authToken  = "your_auth_token";

        TwilioClient.Init(accountSid, authToken);

        var type = new List <string> {
            "carrier"
        };

        var phoneNumber = PhoneNumberResource.Fetch(
            type: type,
            pathPhoneNumber: new Twilio.Types.PhoneNumber("+15108675310")
            );

        Console.WriteLine(phoneNumber.Carrier);
    }
    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 addOnsData = new Dictionary <string, Object>()
        {
            { "payfone_tcpa_compliance.right_party_contacted_date", "20160101" }
        };

        var phoneNumber = PhoneNumberResource.Fetch(
            addOns: Promoter.ListOfOne("payfone_tcpa_compliance"),
            addOnsData: addOnsData,
            pathPhoneNumber: new Twilio.Types.PhoneNumber("+16502530000")
            );

        Console.WriteLine(phoneNumber.CallerName);
    }
    static void Main(string[] args)
    {
        // Find your Account Sid and Token at twilio.com/console
        const string accountSid = "AC1061e132398b5dc01334d9ff9b63d58a";
        const string authToken  = "9e6a04f6a51ef7d32858ac16f83c2727";

        TwilioClient.Init(accountSid, authToken);

        var type = new List <string> {
            "carrier"
        };


        var phoneNumber = PhoneNumberResource.Fetch(
            type: type,
            pathPhoneNumber: new Twilio.Types.PhoneNumber("+61452627666")

            );

        Console.WriteLine(phoneNumber.CountryCode);
    }
Exemple #8
0
    static void Main(string[] args)
    {
        // Find your Account SID and Auth Token at twilio.com/console
        const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string authToken  = "your_auth_token";

        TwilioClient.Init(accountSid, authToken);

        var addOns = new List <string> {
            "payfone_tcpa_compliance"
        };
        var addOnsData = new Dictionary <string, object>
        {
            { "payfone_tcpa_compliance.RightPartyContactedDate", "20160101" }
        };

        var phoneNumber = PhoneNumberResource.Fetch(
            new PhoneNumber("+16502530000"),
            addOns: addOns,
            addOnsData: addOnsData);

        Console.WriteLine(phoneNumber.Carrier);
    }
    static void Main(string[] args)
    {
        // Find your Account SID and Auth Token at twilio.com/console
        // To set up environmental variables, see http://twil.io/secure
        const string accountSid = Environment.GetEnvironmentVariable("TWILIO_ACCOUNT_SID");
        const string authToken  = Environment.GetEnvironmentVariable("TWILIO_AUTH_TOKEN");

        TwilioClient.Init(accountSid, authToken);

        var addOns = new List <string> {
            "payfone_tcpa_compliance"
        };
        var addOnsData = new Dictionary <string, object>
        {
            { "payfone_tcpa_compliance.RightPartyContactedDate", "20160101" }
        };

        var phoneNumber = PhoneNumberResource.Fetch(
            new PhoneNumber("+16502530000"),
            addOns: addOns,
            addOnsData: addOnsData);

        Console.WriteLine(phoneNumber.Carrier);
    }
Exemple #10
0
        public override bool Execute(RockContext rockContext, WorkflowAction action, object entity, out List <string> errorMessages)
        {
            errorMessages = new List <string>();

            string twilioGuid = GetAttributeValue(action, "TwilioTransportContainer");
            string pn         = PhoneNumber.CleanNumber(GetAttributeValue(action, "PhoneNumber", true));

            string[] lookupServices = GetAttributeValue(action, "LookupServices").SplitDelimitedValues();


            if (!string.IsNullOrWhiteSpace(twilioGuid) && !string.IsNullOrWhiteSpace(pn))
            {
                // Add the country code if applicable
                if (pn.Length == 10)
                {
                    var definedValues = DefinedTypeCache.Get(Rock.SystemGuid.DefinedType.COMMUNICATION_PHONE_COUNTRY_CODE.AsGuid()).DefinedValues.OrderBy(v => v.Order);
                    var countryCode   = definedValues.Select(v => v.Value).FirstOrDefault();
                    pn = countryCode + pn;
                }

                var twilio = Rock.Communication.TransportContainer.GetComponent(twilioGuid);
                if (twilio != null)
                {
                    twilio.LoadAttributes();
                    string accountSid = twilio.GetAttributeValue("SID");
                    string authToken  = twilio.GetAttributeValue("Token");
                    TwilioClient.Init(accountSid, authToken);

                    // Setup the lookup(s) to perform
                    var type   = new List <string>();
                    var addOns = new List <string>();
                    foreach (string lookupService in lookupServices)
                    {
                        if (lookupService.ToLower().StartsWith("whitepages"))
                        {
                            addOns.Add(lookupService);
                        }
                        else
                        {
                            type.Add(lookupService);
                        }
                    }

                    // Now do the lookup
                    var phoneNumber = PhoneNumberResource.Fetch(
                        addOns: addOns,
                        type: type,
                        pathPhoneNumber: new global::Twilio.Types.PhoneNumber("+" + pn)
                        );

                    // Now store the target attribute
                    var targetAttribute = AttributeCache.Get(GetActionAttributeValue(action, "ResultsAttribute").AsGuid(), rockContext);
                    if (targetAttribute.EntityTypeId == new Rock.Model.Workflow().TypeId)
                    {
                        action.Activity.Workflow.SetAttributeValue(targetAttribute.Key, phoneNumber.ToJson());
                    }
                    else if (targetAttribute.EntityTypeId == new WorkflowActivity().TypeId)
                    {
                        action.Activity.SetAttributeValue(targetAttribute.Key, phoneNumber.ToJson());
                    }
                }
            }
            return(true);
        }
Exemple #11
0
        static void Main(string[] args)
        {
            string accountSid = "AC8c739ae32c0c508876745f04379bf91f";
            string authToken  = "your_auth_token";

            //mysection
            accountSid = "AC8c739ae32c0c508876745f04379bf91f";
            authToken  = "6078ad0727713f2cc10075aa21e0982c";

            TwilioClient.Init(accountSid, authToken);

            //manual from static
            //var phoneNumber = PhoneNumberResource.Fetch(new PhoneNumber("+15108675309"), "US", new List<string> { "carrier" });

            /*
             *         var phoneNumber1 = PhoneNumberResource.Fetch(new PhoneNumber("(615) 364-6365"), "US");
             *
             *         Console.WriteLine(phoneNumber1.PhoneNumber + "-" + phoneNumber.Carrier);
             *
             *         var phoneNumber2 = PhoneNumberResource.Fetch(new PhoneNumber("(901) 364-6365"), "US");
             *
             *         Console.WriteLine(phoneNumber2.PhoneNumber + "-" + phoneNumber.Carrier);
             */

            BuildList();

            foreach (string pnc in phoneNumberList)
            {
                string looppnc = pnc.Trim();

                if (looppnc.Length > 0)
                {
                    looppnc = looppnc.Replace("(", "").Replace(")", "").Replace("[", "").Replace("]", "").Replace("-", "").Trim();


                    if (looppnc.Substring(0, 1) == "+")
                    {
                    }
                    else
                    {
                        looppnc = "+" + looppnc;
                    }

                    if (looppnc.Substring(1, 2) == "1")
                    {
                    }
                    else
                    {
                        looppnc = looppnc.Substring(0, 1) + "1" + looppnc.Substring(1, looppnc.Length - 1);
                    }
                }

                looppnc = looppnc.Trim();
                //looppnc = "+15108675309";

                string trimtoverify = looppnc.TrimStart('+').TrimStart('1');

                Match  m       = Regex.Match(trimtoverify, @"[\s\(]*((?!1)\d{1})((?!11)\d{2})[-\s\).,]*((?!1)\d{1})\d{2}[-\s.,]*\d{4}[\s]*");
                string pattern = "000%";

                bool ismatch = m.Success;

                if (!ismatch)
                {
                    lstReturnClass.Add(new PhoneNumberClass(looppnc, false, null));
                    invalidnumbercount++;
                }
                else
                {
                    if (looppnc.Length == 12)
                    {
                        if (looppnc == "+10000000000" || looppnc == "+11111111111" || looppnc == "+12222222222" || looppnc == "+13333333333" || looppnc == "+14444444444" || looppnc == "+15555555555" || looppnc == " + 16666666666" || looppnc == " +17777777777" || looppnc == "+18888888888" || looppnc == "+19999999999")
                        //|| looppnc.Contains("000%"))
                        {
                            var phoneNumber = PhoneNumberResource.Fetch(new PhoneNumber(looppnc), type: new List <string> {
                                "caller_name", "caller-name", "carrier"
                            });

                            string carriername = string.Empty;
                            string carriertype = String.Empty;


                            if (phoneNumber.Carrier != null)
                            {
                                carriername = phoneNumber.Carrier["name"];
                                carriertype = phoneNumber.Carrier["type"];
                            }

                            string callername = String.Empty;

                            if (phoneNumber.CallerName != null)
                            {
                                callername = phoneNumber.CallerName["caller_name"];
                            }
                            totalcount++;

                            //Console.WriteLine(phoneNumber.PhoneNumber + "-" + carriername + "-" + carriertype);

                            if (carriertype.ToLower() == "mobile")
                            {
                                lstReturnClass.Add(new PhoneNumberClass(phoneNumber.PhoneNumber.ToString(), true, true, callername));
                                mobilecount++;
                            }
                            else
                            {
                                lstReturnClass.Add(new PhoneNumberClass(phoneNumber.PhoneNumber.ToString(), true, false, callername));
                            }
                        }
                        else
                        {
                            lstReturnClass.Add(new PhoneNumberClass(looppnc, false, null));
                            badnumbercount++;
                        }
                    }
                    else
                    {
                        lstReturnClass.Add(new PhoneNumberClass(looppnc, false, null));
                        badnumbercount++;
                    }
                }
            }



            Console.Out.WriteLine();
            Console.Out.WriteLine("Total Numbers: " + totalcount.ToString() + "/" + "Mobile Numbers: " + mobilecount.ToString() + "/" + "Bad Numbers (Too Short): " + badnumbercount.ToString() + "/Invalid Numbers: " + invalidnumbercount.ToString());
            Console.Out.WriteLine();
            Console.Out.WriteLine();
            Console.Out.WriteLine();

            OutputFinals();

            Console.Out.WriteLine("Press Enter to exit");

            //string s = Console.ReadKey();
            string s = Console.ReadLine();

            System.Environment.Exit(0);
        }