コード例 #1
0
        protected void RecordingBtn_Click(object sender, EventArgs e)
        {
            //StartRecording();
            // Find your Account SID and Auth Token at twilio.com/console
            const string apiKeySid    = "SK0678c0ad0045e85ac68f91d3eca7c87c";
            const string apiKeySecret = "6AQNum22c9t20kZsbGXffSZQDpEyjyWs";

            // const string roomUniqueName = "Anu";
            TwilioClient.Init(apiKeySid, apiKeySecret);
            var rooms = RoomResource.Read(
                status: RoomResource.RoomStatusEnum.Completed,
                //uniqueName: "05212018014523086");
                uniqueName: "05212018045230018");

            foreach (var room in rooms)
            {
                Console.WriteLine(room.Sid);
                string roomSid = room.Sid;
                //Console.WriteLine(room.Sid);

                //const string roomSid = "RM9236a49ad89bde01060d416c418b1157";

                TwilioClient.Init(apiKeySid, apiKeySecret);

                var recordings = RecordingResource.Read(
                    groupingSid: new List <string>()
                {
                    roomSid
                });

                foreach (var recording in recordings)
                {
                    Console.WriteLine(recording.Sid);
                    string recordingSid      = recording.Sid;
                    var    RetrieveRecording = RoomRecordingResource.Fetch(roomSid, recordingSid);
                    Console.WriteLine(RetrieveRecording.Type);
                    string uri = "https://video.twilio.com/v1/" +
                                 $"Rooms/{roomSid}/" +
                                 $"Recordings/{recordingSid}/" +
                                 "Media/";

                    var request = (HttpWebRequest)WebRequest.Create(uri);
                    request.Headers.Add("Authorization", "Basic " + Convert.ToBase64String(Encoding.ASCII.GetBytes(apiKeySid + ":" + apiKeySecret)));
                    request.AllowAutoRedirect = false;
                    string responseBody  = new StreamReader(request.GetResponse().GetResponseStream()).ReadToEnd();
                    var    mediaLocation = JsonConvert.DeserializeObject <Dictionary <string, string> >(responseBody)["redirect_to"];

                    Console.WriteLine(mediaLocation);
                    //aws credentials;
                    //loc = aws

                    new WebClient().DownloadFile(mediaLocation, @"C:\Users\bhanushree.rajanna\Desktop\TestR\" + recording.TrackName + RetrieveRecording.Type + "AudioVideo.mp4");
                }
            }
        }
コード例 #2
0
        // [WebMethod]
        //   public static void StartRecording()
        //    {
        //ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "Func()", true);


        //     }
        //}
        protected void RecordingBtnn_Click(object sender, EventArgs e)
        {
            //StartRecording();
            // Find your Account SID and Auth Token at twilio.com/console
            const string apiKeySid    = "SKd8aac04eba0fa8ed056c6263990fa85c";
            const string apiKeySecret = "uUiLZ8XytHGuo15BPnU4EuZ5kdywBDWO";

            // const string roomUniqueName = "Anu";
            TwilioClient.Init(apiKeySid, apiKeySecret);
            var rooms = RoomResource.Read(
                status: RoomResource.RoomStatusEnum.Completed,
                //uniqueName: "05212018045230018");
                uniqueName: "05212018075717994");

            foreach (var room in rooms)
            {
                Console.WriteLine(room.Sid);
                string roomSid = room.Sid;
                //Console.WriteLine(room.Sid);

                //const string roomSid = "RM9236a49ad89bde01060d416c418b1157";

                TwilioClient.Init(apiKeySid, apiKeySecret);

                var recordings = RecordingResource.Read(
                    groupingSid: new List <string>()
                {
                    roomSid
                });

                foreach (var recording in recordings)
                {
                    Console.WriteLine(recording.Sid);
                    string recordingSid      = recording.Sid;
                    var    RetrieveRecording = RoomRecordingResource.Fetch(roomSid, recordingSid);
                    Console.WriteLine(RetrieveRecording.Type);
                    string uri = "https://video.twilio.com/v1/" +
                                 $"Rooms/{roomSid}/" +
                                 $"Recordings/{recordingSid}/" +
                                 "Media/";

                    var request = (HttpWebRequest)WebRequest.Create(uri);
                    request.Headers.Add("Authorization", "Basic " + Convert.ToBase64String(Encoding.ASCII.GetBytes(apiKeySid + ":" + apiKeySecret)));
                    request.AllowAutoRedirect = false;
                    string responseBody  = new StreamReader(request.GetResponse().GetResponseStream()).ReadToEnd();
                    var    mediaLocation = JsonConvert.DeserializeObject <Dictionary <string, string> >(responseBody)["redirect_to"];

                    Console.WriteLine(mediaLocation);
                    new WebClient().DownloadFile(mediaLocation, @"C:\Users\bhanushree.rajanna\Desktop\TransferToAmazonVideoFolder" + recording.TrackName + RetrieveRecording.Type + "AudioVideo.mp4");
                }
            }
        }
コード例 #3
0
        // [WebMethod]
        //   public static void StartRecording()
        //    {
        //ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "Func()", true);


        //     }
        //}

        protected void RecordingBtn_Click(object sender, EventArgs e)
        {
            //StartRecording();
            // Find your Account SID and Auth Token at twilio.com/console
            const string apiKeySid    = "SK26a5ad58fe67cd4192caf9d49c11e160";
            const string apiKeySecret = "3ROMylcwSwpUCn0ROstqRgSWmGr4alvk";

            // const string roomUniqueName = "Anu";
            TwilioClient.Init(apiKeySid, apiKeySecret);
            var rooms = RoomResource.Read(
                status: RoomResource.RoomStatusEnum.Completed,
                uniqueName: "Room");

            foreach (var room in rooms)
            {
                Console.WriteLine(room.Sid);
                string roomSid = room.Sid;
                //Console.WriteLine(room.Sid);

                //const string roomSid = "RM9236a49ad89bde01060d416c418b1157";

                TwilioClient.Init(apiKeySid, apiKeySecret);

                var recordings = RecordingResource.Read(
                    groupingSid: new List <string>()
                {
                    roomSid
                });

                foreach (var recording in recordings)
                {
                    Console.WriteLine(recording.Sid);
                    string recordingSid      = recording.Sid;
                    var    RetrieveRecording = RoomRecordingResource.Fetch(roomSid, recordingSid);
                    Console.WriteLine(RetrieveRecording.Type);
                    string uri = "https://video.twilio.com/v1/" +
                                 $"Rooms/{roomSid}/" +
                                 $"Recordings/{recordingSid}/" +
                                 "Media/";

                    var request = (HttpWebRequest)WebRequest.Create(uri);
                    request.Headers.Add("Authorization", "Basic " + Convert.ToBase64String(Encoding.ASCII.GetBytes(apiKeySid + ":" + apiKeySecret)));
                    request.AllowAutoRedirect = false;
                    string responseBody  = new StreamReader(request.GetResponse().GetResponseStream()).ReadToEnd();
                    var    mediaLocation = JsonConvert.DeserializeObject <Dictionary <string, string> >(responseBody)["redirect_to"];

                    Console.WriteLine(mediaLocation);
                    new WebClient().DownloadFile(mediaLocation, @"C:\Users\bhanushree.rajanna\Desktop\videostore\" + recording.TrackName + RetrieveRecording.Type + "Room.mp4");
                }
            }
        }
コード例 #4
0
        public void TestReadResultsResponse()
        {
            var twilioRestClient = Substitute.For <ITwilioRestClient>();

            twilioRestClient.AccountSid.Returns("ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
            twilioRestClient.Request(Arg.Any <Request>())
            .Returns(new Response(
                         System.Net.HttpStatusCode.OK,
                         "{\"recordings\": [{\"account_sid\": \"ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"status\": \"completed\",\"date_created\": \"2015-07-30T20:00:00Z\",\"sid\": \"RTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"source_sid\": \"MTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"size\": 23,\"type\": \"audio\",\"duration\": 10,\"container_format\": \"mka\",\"codec\": \"OPUS\",\"grouping_sids\": {\"room_sid\": \"RMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"participant_sid\": \"PAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"},\"media_external_location\": \"https://my-super-duper-bucket.s3.amazonaws.com/my/path/\",\"encryption_key\": \"public_key\",\"url\": \"https://video.twilio.com/v1/Recordings/RTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"links\": {\"media\": \"https://video.twilio.com/v1/Recordings/RTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Media\"}}],\"meta\": {\"page\": 0,\"page_size\": 50,\"first_page_url\": \"https://video.twilio.com/v1/Recordings?PageSize=50&Page=0\",\"previous_page_url\": null,\"url\": \"https://video.twilio.com/v1/Recordings?PageSize=50&Page=0\",\"next_page_url\": null,\"key\": \"recordings\"}}"
                         ));

            var response = RecordingResource.Read(client: twilioRestClient);

            Assert.NotNull(response);
        }
コード例 #5
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 recordings = RecordingResource.Read();

        foreach (var recording in recordings)
        {
            Console.WriteLine(recording.CallSid);
        }
    }
コード例 #6
0
        public void TestReadResultsResponse()
        {
            var twilioRestClient = Substitute.For <ITwilioRestClient>();

            twilioRestClient.AccountSid.Returns("ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
            twilioRestClient.Request(Arg.Any <Request>())
            .Returns(new Response(
                         System.Net.HttpStatusCode.OK,
                         "{\"recordings\": [{\"account_sid\": \"ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"status\": \"completed\",\"date_created\": \"2015-07-30T20:00:00Z\",\"date_updated\": \"2015-07-30T21:00:00Z\",\"date_deleted\": \"2015-07-30T22:00:00Z\",\"sid\": \"RTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"source_sid\": \"MTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"size\": 23,\"type\": \"audio\",\"duration\": 10,\"container_format\": \"mka\",\"codec\": \"OPUS\",\"track_name\": \"A name\",\"offset\": 10,\"grouping_sids\": {\"room_sid\": \"RMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"participant_sid\": \"PAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"},\"media_external_location\": \"https://www.twilio.com\",\"encryption_key\": \"public_key\",\"url\": \"https://video.twilio.com/v1/Recordings/RTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"links\": {\"media\": \"https://video.twilio.com/v1/Recordings/RTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Media\"}}],\"meta\": {\"page\": 0,\"page_size\": 50,\"first_page_url\": \"https://video.twilio.com/v1/Recordings?Status=completed&DateCreatedAfter=2017-01-01T00%3A00%3A01Z&DateCreatedBefore=2017-12-31T23%3A59%3A59Z&SourceSid=source_sid&MediaType=audio&GroupingSid=RMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&PageSize=50&Page=0\",\"previous_page_url\": null,\"url\": \"https://video.twilio.com/v1/Recordings?Status=completed&DateCreatedAfter=2017-01-01T00%3A00%3A01Z&DateCreatedBefore=2017-12-31T23%3A59%3A59Z&SourceSid=source_sid&MediaType=audio&GroupingSid=RMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&PageSize=50&Page=0\",\"next_page_url\": null,\"key\": \"recordings\"}}"
                         ));

            var response = RecordingResource.Read(client: twilioRestClient);

            Assert.NotNull(response);
        }
コード例 #7
0
        public void TestReadEmptyResponse()
        {
            var twilioRestClient = Substitute.For <ITwilioRestClient>();

            twilioRestClient.AccountSid.Returns("ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
            twilioRestClient.Request(Arg.Any <Request>())
            .Returns(new Response(
                         System.Net.HttpStatusCode.OK,
                         "{\"recordings\": [],\"meta\": {\"page\": 0,\"page_size\": 50,\"first_page_url\": \"https://video.twilio.com/v1/Recordings?PageSize=50&Page=0\",\"previous_page_url\": null,\"url\": \"https://video.twilio.com/v1/Recordings?PageSize=50&Page=0\",\"next_page_url\": null,\"key\": \"recordings\"}}"
                         ));

            var response = RecordingResource.Read(client: twilioRestClient);

            Assert.NotNull(response);
        }
コード例 #8
0
        public void TestReadFullResponse()
        {
            var twilioRestClient = Substitute.For <ITwilioRestClient>();

            twilioRestClient.AccountSid.Returns("ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
            twilioRestClient.Request(Arg.Any <Request>())
            .Returns(new Response(
                         System.Net.HttpStatusCode.OK,
                         "{\"end\": 0,\"first_page_uri\": \"/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings.json?PageSize=1&Page=0\",\"last_page_uri\": \"/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings.json?PageSize=1&Page=4\",\"next_page_uri\": null,\"num_pages\": 5,\"page\": 0,\"page_size\": 1,\"previous_page_uri\": null,\"recordings\": [{\"account_sid\": \"ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"api_version\": \"2008-08-01\",\"call_sid\": \"CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"date_created\": \"Wed, 22 Aug 2012 20:58:45 +0000\",\"date_updated\": \"Wed, 22 Aug 2012 20:58:45 +0000\",\"duration\": null,\"price\": \"0.04\",\"sid\": \"REaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"price_unit\": \"USD\",\"status\": \"completed\",\"channels\": 1,\"source\": \"Trunking\",\"uri\": \"/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings/REaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json\"}],\"start\": 0,\"total\": 5,\"uri\": \"/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings.json?PageSize=1&Page=0\"}"
                         ));

            var response = RecordingResource.Read(client: twilioRestClient);

            Assert.NotNull(response);
        }
コード例 #9
0
        public void TestReadEmptyResponse()
        {
            var twilioRestClient = Substitute.For <ITwilioRestClient>();

            twilioRestClient.AccountSid.Returns("ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
            twilioRestClient.Request(Arg.Any <Request>())
            .Returns(new Response(
                         System.Net.HttpStatusCode.OK,
                         "{\"end\": 0,\"first_page_uri\": \"/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings.json?PageSize=1&Page=0\",\"last_page_uri\": \"/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings.json?PageSize=1&Page=4\",\"next_page_uri\": null,\"num_pages\": 5,\"page\": 0,\"page_size\": 1,\"previous_page_uri\": null,\"recordings\": [],\"start\": 0,\"total\": 5,\"uri\": \"/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings.json?PageSize=1&Page=0\"}"
                         ));

            var response = RecordingResource.Read(client: twilioRestClient);

            Assert.NotNull(response);
        }
コード例 #10
0
        public void TestReadFullResponse()
        {
            var twilioRestClient = Substitute.For <ITwilioRestClient>();

            twilioRestClient.AccountSid.Returns("ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
            twilioRestClient.Request(Arg.Any <Request>())
            .Returns(new Response(
                         System.Net.HttpStatusCode.OK,
                         "{\"end\": 0,\"first_page_uri\": \"/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conferences/CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings.json?PageSize=50&Page=0\",\"next_page_uri\": null,\"page\": 0,\"page_size\": 50,\"previous_page_uri\": null,\"recordings\": [{\"account_sid\": \"ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"api_version\": \"2010-04-01\",\"call_sid\": \"CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"conference_sid\": \"CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"channels\": \"1\",\"date_created\": \"Fri, 14 Oct 2016 21:56:34 +0000\",\"date_updated\": \"Fri, 14 Oct 2016 21:56:38 +0000\",\"start_time\": \"Fri, 14 Oct 2016 21:56:34 +0000\",\"end_time\": \"Fri, 14 Oct 2016 21:56:38 +0000\",\"price\": \"-0.0025\",\"price_unit\": \"USD\",\"duration\": \"4\",\"sid\": \"REaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"source\": \"StartConferenceRecordingAPI\",\"status\": \"completed\",\"error_code\": null,\"encryption_details\": {\"encryption_public_key_sid\": \"CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"encryption_cek\": \"OV4h6zrsxMIW7h0Zfqwfn6TI2GCNl54KALlg8wn8YB8KYZhXt6HlgvBWAmQTlfYVeLWydMiCewY0YkDDT1xmNe5huEo9vjuKBS5OmYK4CZkSx1NVv3XOGrZHpd2Pl/5WJHVhUK//AUO87uh5qnUP2E0KoLh1nyCLeGcEkXU0RfpPn/6nxjof/n6m6OzZOyeIRK4Oed5+rEtjqFDfqT0EVKjs6JAxv+f0DCc1xYRHl2yV8bahUPVKs+bHYdy4PVszFKa76M/Uae4jFA9Lv233JqWcxj+K2UoghuGhAFbV/JQIIswY2CBYI8JlVSifSqNEl9vvsTJ8bkVMm3MKbG2P7Q==\",\"encryption_iv\": \"8I2hhNIYNTrwxfHk\"},\"uri\": \"/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conferences/CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings.json\"}],\"start\": 0,\"uri\": \"/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conferences/CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings.json?PageSize=50&Page=0\"}"
                         ));

            var response = RecordingResource.Read("CFXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", client: twilioRestClient);

            Assert.NotNull(response);
        }
コード例 #11
0
    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 recordings = RecordingResource.Read();

        foreach (var recording in recordings)
        {
            Console.WriteLine(recording.CallSid);
        }
    }
コード例 #12
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 recordings = RecordingResource.Read(limit: 20);

        foreach (var record in recordings)
        {
            Console.WriteLine(record.Sid);
        }
    }
コード例 #13
0
    static void Main(string[] args)
    {
        // Find your Account SID and Auth Token at twilio.com/console
        const string apiKeySid    = "SKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string apiKeySecret = "your_api_key_secret";

        TwilioClient.Init(apiKeySid, apiKeySecret);

        var recordings = RecordingResource.Read(
            status: RecordingResource.StatusEnum.Deleted);

        foreach (var recording in recordings)
        {
            Console.WriteLine(recording.Sid);
        }
    }
コード例 #14
0
    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 recordings = RecordingResource.Read(
            groupingSid: Promoter.ListOfOne("ParticipantSid")
            );

        foreach (var record in recordings)
        {
            Console.WriteLine(record.Sid);
        }
    }
コード例 #15
0
    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 apiKeySid    = Environment.GetEnvironmentVariable("TWILIO_API_KEY_SID");
        const string apiKeySecret = Environment.GetEnvironmentVariable("TWILIO_API_KEY_SECRET");

        TwilioClient.Init(apiKeySid, apiKeySecret);

        var recordings = RecordingResource.Read(
            status: RecordingResource.StatusEnum.Deleted);

        foreach (var recording in recordings)
        {
            Console.WriteLine(recording.Sid);
        }
    }
コード例 #16
0
    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 recordings = RecordingResource.Read(
            dateCreated: new DateTime(2016, 10, 18, 0, 0, 0)
            );

        foreach (var record in recordings)
        {
            Console.WriteLine(record.Sid);
        }
    }
コード例 #17
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 recordings = RecordingResource.Read(
            dateCreatedBefore: new DateTime(2016, 10, 15, 0, 0, 0),
            dateCreatedAfter: new DateTime(2016, 10, 12, 0, 0, 0)
            );

        foreach (var record in recordings)
        {
            Console.WriteLine(record.Sid);
        }
    }
コード例 #18
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";
        const string roomSid    = "RMXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";

        TwilioClient.Init(accountSid, authToken);

        var recordings = RecordingResource.Read(
            groupingSid: new List <string>()
        {
            roomSid
        });

        foreach (var recording in recordings)
        {
            Console.WriteLine(recording.Sid);
        }
    }
コード例 #19
0
        public void TestReadRequest()
        {
            var twilioRestClient = Substitute.For <ITwilioRestClient>();
            var request          = new Request(
                HttpMethod.Get,
                Twilio.Rest.Domain.Video,
                "/v1/Recordings",
                ""
                );

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

            try
            {
                RecordingResource.Read(client: twilioRestClient);
                Assert.Fail("Expected TwilioException to be thrown for 500");
            }
            catch (ApiException) {}
            twilioRestClient.Received().Request(request);
        }
コード例 #20
0
    static void Main(string[] args)
    {
        // Find your Account SID and Auth Token at twilio.com/console
        const string apiKeySid    = "SKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string apiKeySecret = "your_api_key_secret";
        const string roomSid      = "RMXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";

        TwilioClient.Init(apiKeySid, apiKeySecret);

        var recordings = RecordingResource.Read(
            groupingSid: new List <string>()
        {
            roomSid
        });

        foreach (var recording in recordings)
        {
            Console.WriteLine(recording.Sid);
        }
    }
コード例 #21
0
        public void TestReadRequest()
        {
            var twilioRestClient = Substitute.For <ITwilioRestClient>();
            var request          = new Request(
                HttpMethod.Get,
                Twilio.Rest.Domain.Api,
                "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings.json",
                ""
                );

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

            try
            {
                RecordingResource.Read(client: twilioRestClient);
                Assert.Fail("Expected TwilioException to be thrown for 500");
            }
            catch (ApiException) {}
            twilioRestClient.Received().Request(request);
        }
コード例 #22
0
        /// <summary>
        /// This Functions goes to Twilio, make a call, Twilio save a record of this call then goes to Google Speech to text API and transcribe the call saving a txt local file
        /// </summary>
        public static void Call()
        {
            Console.WriteLine("Init Twilio API...");
            ///Twilio SID and Token
            const string accountSid = "ACa62c3db32794048447xxxxxxxxxxxx";
            const string authToken  = "f420e52ee6774e0898fdxxxxxxxxxxxx";

            TwilioClient.Init(accountSid, authToken);
            Console.WriteLine("Let's make a call, please provide me your phone number (format: +AreaNumner)");
            var phoneNumber = Console.ReadLine();
            var call        = CallResource.Create(
                record: true,
                url: new Uri("https://corn-collie-1715.twil.io/assets/Voice.xml"), //is a best practice to upload the assets in twilio account
                to: new Twilio.Types.PhoneNumber(phoneNumber),
                from: new Twilio.Types.PhoneNumber("+000000000")                   //Twilio number created in you account
                );

            RecordingResource recordings;

            RecordingResource.StatusEnum recordingStatus;

            do
            {
                recordings = RecordingResource.Read().Where(x => x.CallSid == call.Sid).FirstOrDefault();
            } while (recordings == null);

            do
            {
                Console.WriteLine("Processing Recording....");
                recordingStatus = RecordingResource.Read().Where(x => x.CallSid == call.Sid).Select(x => x.Status).FirstOrDefault();
            } while (recordingStatus == RecordingResource.StatusEnum.Processing);

            WebClient wc = new WebClient();

            wc.DownloadFile(@"https://api.twilio.com/" + recordings.Uri.Replace("json", "wav"), recordings.Sid + ".wav");
            Console.WriteLine("Now we have the recording,Lets sync with Google Services, please wait... ");
            string audioDirectory = Path.Combine(Environment.CurrentDirectory, recordings.Sid + ".wav");
            var    memoryStream   = new MemoryStream();

            using (var file = new FileStream(audioDirectory, FileMode.Open, FileAccess.Read))
                file.CopyTo(memoryStream);

            var speechClient  = SpeechClient.Create();
            var storageClient = StorageClient.Create();

            //We have to upload the file to google storage before transcribe
            var uploadedWavFile = storageClient.UploadObject(GoogleBucketName, recordings.Sid + ".wav", "audio/wav", memoryStream);

            //Get the file
            var storageObject = storageClient.GetObject(GoogleBucketName, recordings.Sid + ".wav");
            var storageUri    = $@"gs://{GoogleBucketName}/{storageObject.Name}";

            storageObject.Acl = storageObject.Acl ?? new List <ObjectAccessControl>();
            storageClient.UpdateObject(storageObject, new UpdateObjectOptions
            {
                PredefinedAcl = PredefinedObjectAcl.PublicRead
            });

            Console.WriteLine("We will start to transcribe your recording, this operation will take few moments...");
            //Speech to Text operation
            var longOperation = speechClient.LongRunningRecognize(new RecognitionConfig()
            {
                //the properties below are not the required for MP3 files and that's why the opertion returns null, we can make this more
                //generic knowing what kind of properties we need for each file type or standarize the result just for one type.
                //Encoding = RecognitionConfig.Types.AudioEncoding.Linear16,
                //SampleRateHertz = 44100,
                EnableWordTimeOffsets = true,
                LanguageCode          = "en-US"
            }, RecognitionAudio.FromStorageUri(storageUri));

            longOperation = longOperation.PollUntilCompleted();
            //TODO: fix this implementation. Sometimes there is a null being returned from longOperation.Result
            var response = longOperation.Result;

            if (response != null && response.Results != null && response.Results.Count > 0)
            {
                Console.WriteLine("Is done!, now we will create a file with the complete transcription for you...");
                //var resultArray = (JsonConvert.DeserializeObject<RootObject>(response.Results.ToString()));
                foreach (var res in response.Results)
                {
                    string transcription = res.Alternatives.Select(x => x.Transcript).FirstOrDefault();
                    File.AppendAllText(Path.Combine(Environment.CurrentDirectory, recordings.Sid + ".txt"), transcription);
                }
            }
            Console.WriteLine("File Created!, Now we will clean our directories and give you the path of the mentioned file...");
            storageClient.DeleteObject(GoogleBucketName, storageObject.Name);

            if (File.Exists(Path.Combine(Environment.CurrentDirectory, recordings.Sid + ".wav")))
            {
                File.Delete(Path.Combine(Environment.CurrentDirectory, recordings.Sid + ".wav"));
            }

            Console.WriteLine("You can find your txt file here: " + Path.Combine(Environment.CurrentDirectory, recordings.Sid + ".txt"));
            Console.ReadLine();
        }
コード例 #23
0
        public async Task <string> CallMeetingAsync(string mNum)
        {
            Console.WriteLine(">\tDialing into webex meeting with access code " + mNum);
            TwilioClient.Init(_accountSid, _authToken);

            // call in number and call from number
            const string vancouverTollNum = "+14084189388";
            const string twilioAccNum     = "+15046366992";

            // this is the webex call vancouver toll number
            var to = new PhoneNumber(vancouverTollNum);

            // This is the twilio number linked to our account
            var from = new PhoneNumber(twilioAccNum);

            Console.WriteLine(">\tCalling In...");
            // makes the call resource to send
            var call = CallResource.Create(to, from,
                                           //method: Twilio.Http.HttpMethod.Get,
                                           sendDigits: FormatDigits(mNum) + "wwww#",
                                           // Records the outgoing call
                                           record: true,
                                           // default message that plays from the url
                                           url: new Uri("http://lonelycompany.ca/test.xml")

                                           );

            var callSid = call.Sid;

            // set status to default value
            CallResource.StatusEnum status = CallResource.StatusEnum.Queued;

            // for checking what Sid was used in the loop
            CallResource finishedCall = null;

            // wait for meeting to finish
            while (status != CallResource.StatusEnum.Completed)
            {
                // return all the call resources for account user
                var calls = CallResource.ReadAsync().Result;

                // find element in list
                finishedCall = calls.First(record => record.Sid == callSid);
                var pendingStatus = finishedCall.Status;

                if (pendingStatus == CallResource.StatusEnum.Ringing)
                {
                    Console.WriteLine(">\tRinging...");
                    status = pendingStatus;
                }
                else if (pendingStatus == CallResource.StatusEnum.InProgress &&
                         status == pendingStatus)
                {
                    Console.WriteLine(">\tCalled in!");
                    status = pendingStatus;
                }

                // check if the record is
                if (pendingStatus == CallResource.StatusEnum.Completed)
                {
                    Console.WriteLine(">\tCall Completed");
                    // if the call has been completed return the completed status
                    status = pendingStatus;
                }
                else if (status == CallResource.StatusEnum.Canceled ||
                         status == CallResource.StatusEnum.Failed ||
                         status == CallResource.StatusEnum.NoAnswer)
                {
                    Console.Error.WriteLine(">\tThe call was not completed.");
                    break;
                }
            }

            //var subresourceUri = finishedCall.SubresourceUris;


            // retrieve 10 most recent recordings
            var recordings      = RecordingResource.Read(limit: 10);
            var resultRecording = recordings.First(recording => recording.CallSid == callSid);

            //Console.WriteLine("The recording call sid is: " + resultRecording.CallSid);
            //Console.WriteLine("The recording sid is: " + resultRecording.Sid);

            return(resultRecording.Sid);
        }