Ejemplo n.º 1
0
        static async Task ValidateRulesAsync(TwitterContext twitterCtx)
        {
            var rules = new List <StreamingAddRule>
            {
                new StreamingAddRule {
                    Tag = "memes with media", Value = "meme has:images"
                },
                new StreamingAddRule {
                    Tag = "cats with media", Value = "cat has:media"
                }
            };

            Streaming?result = await twitterCtx.AddStreamingFilterRulesAsync(rules, isValidateOnly : true);

            if (result?.Meta?.Summary != null)
            {
                StreamingMeta meta = result.Meta;
                Console.WriteLine($"\nSent: {meta.Sent}");

                StreamingMetaSummary summary = meta.Summary;

                Console.WriteLine($"Created:  {summary.Created}");
                Console.WriteLine($"!Created: {summary.NotCreated}");
            }

            if (result?.Errors != null && result.HasErrors)
            {
                result.Errors.ForEach(error =>
                                      Console.WriteLine(
                                          $"\nTitle: {error.Title}" +
                                          $"\nValue: {error.Value}" +
                                          $"\nID:    {error.ID}" +
                                          $"\nType:  {error.Type}"));
            }
        }
Ejemplo n.º 2
0
        static async Task AddRulesAsync(TwitterContext twitterCtx)
        {
            var rules = new List <StreamingAddRule>
            {
                new StreamingAddRule {
                    Tag = "some things", Value = "Katumbiti"
                },
            };

            Streaming?result = await twitterCtx.AddStreamingFilterRulesAsync(rules);

            Console.WriteLine(result.Ids);
            StreamingMeta?meta = result?.Meta;

            if (meta?.Summary != null)
            {
                Console.WriteLine($"\nSent: {meta.Sent}");

                StreamingMetaSummary summary = meta.Summary;

                Console.WriteLine($"Created:  {summary.Created}");
                Console.WriteLine($"!Created: {summary.NotCreated}");
            }

            if (result?.Errors != null && result.HasErrors)
            {
                result.Errors.ForEach(error =>
                                      Console.WriteLine(
                                          $"\nTitle: {error.Title}" +
                                          $"\nValue: {error.Value}" +
                                          $"\nID:    {error.ID}" +
                                          $"\nType:  {error.Type}"));
            }
        }
Ejemplo n.º 3
0
        static async Task DeleteRulesAsync(TwitterContext twitterCtx)
        {
            var ruleIds = new List <string>
            {
                "1367859000629411840",
                "1367855205170221057",
                "1367855205170221058"
            };

            Streaming?result = await twitterCtx.DeleteStreamingFilterRulesAsync(ruleIds);

            if (result?.Meta?.Summary != null)
            {
                StreamingMeta meta = result.Meta;
                Console.WriteLine($"\nSent: {meta.Sent}");

                StreamingMetaSummary summary = meta.Summary;

                Console.WriteLine($"Deleted:  {summary.Deleted}");
                Console.WriteLine($"!Deleted: {summary.NotDeleted}");
            }

            if (result?.Errors != null && result.HasErrors)
            {
                result.Errors.ForEach(error =>
                                      Console.WriteLine(
                                          $"\nTitle: {error.Title}" +
                                          $"\nValue: {error.Value}" +
                                          $"\nID:    {error.ID}" +
                                          $"\nType:  {error.Type}"));
            }
        }