コード例 #1
0
        public void Send(string[] numbers, string message)
        {
            var api  = new PlivoApi(_authId, _authToken);
            var resp = api.Message.Create(_fromNumber, numbers.ToList(), message);

            log.DebugFormat("{0} - {1}: {2}", resp.ApiId, resp.Message, string.Join(", ", resp.MessageUuid));
        }
コード例 #2
0
        static void CallHim()
        {
            var api = new PlivoApi(AuthId, AuthToken);

            try
            {
                string uuid = Calls.Peek();
                Console.WriteLine("Call Ended By: {0}", api.Call.Get(uuid).HangupSource);
            }
            catch (Exception ex) {
                Console.WriteLine(ex.ToString());
            }
            var response = api.Call.Create(
                to: new List <String> {
                "12024561414"
            },
                from: GetRandomTelNo(),
                answerMethod: "GET",
                answerUrl: "https://phlorunner.plivo.com/v1/account/MAYTE2YWY1OGVMZGVLYJ/phlo/236a4eee-bc34-4b51-82ce-2e2195e69a41"
                );

            memid = response.RequestUuid;
            Calls.Enqueue(response.RequestUuid);
            if (Calls.Count > 10)
            {
                Calls.Dequeue();
            }
            Console.WriteLine(response);
        }
コード例 #3
0
ファイル: PhloInterface.cs プロジェクト: loki-NK/plivo-dotnet
        public string GetAccountID()
        {
            var api       = new PlivoApi(_authId, _authToken);
            var accountId = api.Account.Get().Id;

            return(accountId);
        }
コード例 #4
0
        /// <summary>
        /// Function for sending sms
        /// </summary>
        /// <param name="receiver">Number of the receiver, must be "+XXZZZZZZZZ"</param>
        /// <param name="sender">Could really be anything as a string, even text</param>
        /// <param name="message">Message to send. Keep it short</param>
        /// <returns>Send sms result</returns>
        public async override Task <bool> Send(string receiver, string sender, string message)
        {
            var api = new PlivoApi(config.authId, config.authToken);

            var response = api.Message.Create(
                src: sender,
                dst: new List <String> {
                receiver
            },
                text: message
                );

            if (response.StatusCode != 202)
            {
                return(false);
            }

            return(true);
        }
コード例 #5
0
 public (bool, Exception) SendMessage(string fromNumber, string toNumber, string text)
 {
     try
     {
         var plivoApi = new PlivoApi(_pilvoAuthId, _pilvoAuthToken);
         plivoApi.Message.Create(
             dst: new List <String> {
             toNumber
         },
             src: fromNumber,
             text: text
             );
         return(true, null);
     }
     catch (Exception ex)
     {
         return(false, ex);
     }
 }
コード例 #6
0
        static void Main(string[] args)
        {
            var   api = new PlivoApi(AuthId, AuthToken);
            Timer t   = new Timer(60000);

            t.Elapsed += T_Elapsed;
            //t.Start();
            string input1 = "";

            do
            {
                Console.Write(Environment.NewLine + ">");
                input1 = Console.ReadLine();
                if (input1 == "x")
                {
                    break;
                }
                else if (input1 == "startt")
                {
                    t.Start();
                }
                else if (input1 == "stopt")
                {
                    t.Stop();
                }
                else if (input1 == "ti")
                {
                    Console.WriteLine("New timer Interval>");
                    Double i = 15;
                    if (Double.TryParse(Console.ReadLine(), out i))
                    {
                        t.Interval = i * 1000;
                        Console.WriteLine("New Timer Set to {0} seconds.", t.Interval / 1000);
                    }
                }
                else if (input1 == "sm")
                {
                    try
                    {
                        var x  = api.Conference.List();
                        var cn = x.Conferences[0];
                        foreach (var mem in api.Conference.Get(cn).Members)
                        {
                            Console.WriteLine(mem.MemberId);;
                            memme = mem.MemberId;
                            api.Call.StartRecording(mem.CallUuid, 1440);
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.ToString());
                    }
                }
                else if (input1 == "l")
                {
                    try
                    {
                        var x  = api.Conference.List();
                        var cn = x.Conferences[0];
                        foreach (var mem in api.Conference.Get(cn).Members)
                        {
                            Console.WriteLine(mem.MemberId);;
                        }
                    } catch (Exception ex)
                    {
                        Console.WriteLine(ex.ToString());
                    }
                }
                else if (input1 == "m")
                {
                    var response = api.Call.Create(
                        to: new List <String> {
                        UserPhoneNumber
                    },
                        from: GetRandomTelNo(),
                        answerMethod: "GET",
                        answerUrl: "https://phlorunner.plivo.com/v1/account/MAYTE2YWY1OGVMZGVLYJ/phlo/8432e26d-18b2-4bac-b222-7fe445c7c418" // "https://phlorunner.plivo.com/v1/account/MAYTE2YWY1OGVMZGVLYJ/phlo/236a4eee-bc34-4b51-82ce-2e2195e69a41"
                        );
                    Console.WriteLine(response);
                }
                else if (input1 == "da")
                {
                    try
                    {
                        var x  = api.Conference.List();
                        var cn = x.Conferences[0];
                        foreach (var mem in api.Conference.Get(cn).Members)
                        {
                            Console.WriteLine(mem.MemberId);;
                            if (memme != mem.MemberId)
                            {
                                api.Conference.HangupMember(cn, mem.MemberId);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.ToString());
                    }
                }
                else if (input1 == "del")
                {
                    try
                    {
                        var x = api.Conference.List();
                        api.Conference.Delete(x.Conferences[0]);
                    }
                    catch { }
                }
                else
                {
                    var response = api.Call.Create(
                        to: new List <String> {
                        "12024561414"
                    },
                        from: GetRandomTelNo(),
                        answerMethod: "GET",
                        answerUrl: "https://phlorunner.plivo.com/v1/account/MAYTE2YWY1OGVMZGVLYJ/phlo/8432e26d-18b2-4bac-b222-7fe445c7c418" // "https://phlorunner.plivo.com/v1/account/MAYTE2YWY1OGVMZGVLYJ/phlo/236a4eee-bc34-4b51-82ce-2e2195e69a41"
                        );
                    Console.WriteLine(response);
                }
            } while (true);
        }
コード例 #7
0
 /// <summary>
 /// Plivo implementation constructor
 /// </summary>
 /// <param name="authId">Plivo auth id</param>
 /// <param name="authToken">Plivo auth token</param>
 /// <param name="serviceSource">Service name that the recipient will see</param>
 public SMSNotify(string authId, string authToken, string serviceSource) : base(authId, authToken, serviceSource)
 {
     api = new PlivoApi(authId, authToken);
 }
コード例 #8
0
ファイル: BaseTestCase.cs プロジェクト: vpyasi/plivo-dotnet
 public BaseTestCase()
 {
     Api                = new PlivoApi("MAXXXXXXXXXXXXXXXXXX", "AbcdEfghIjklMnop1234");
     TestClient         = new TestClient();
     Api.Client._client = TestClient;
 }