Quantcast
Channel: Tweetinvi a friendly Twitter C# library
Viewing all articles
Browse latest Browse all 4126

New Post: How to run a code when a given user tweets something?

$
0
0
Thanks for the Reply again, I am beginning to understand things now.
But I just have a few more questions and a little problem (below)

From what I understood so far I prepared this code:
            IToken token = new Token("My Access token", "My Access token secret", "My Consumer key", "My Consumer secret"); // Set your credentials here.
            List<IUser> myFriendsToUpdate = new List<IUser>
            {
                new User("someoneimportant"),
            };

            IUserStream us = new UserStream();
            us.TweetCreatedByAnyone += (sender, args) =>
            {
                var senderScreenName = args.Value.Creator.ScreenName;
                if (myFriendsToUpdate.Select(x => x.ScreenName).Contains(senderScreenName))
                {
                    Console.WriteLine("someoneimportant just tweeted something!");
                }
            };
            us.StartStream(token);
This is the code I tried.
But it did not work.

Problems:
  • Problem 1 - A local variable named 'sender' cannot be declared in this scope because it would give a different meaning to 'sender', which is already used in a 'parent or current' scope to denote something else.
  • Problem 2 - The program would freeze once I run the command above.
Questions:
  • Question 1 - Is my way of writing the tokens and keys wrong? If so Did I mess up the order or what I had to write?
  • Question 2 - Do I need to run the code once or do I need to keep refreshing it. I would imagine that I would have to run it once since it constantly fetches data from the stream.
  • Question 3 - Is it normal that my Program Freezes? Can I run the code above and still maintain functionality for the rest of the form? (I am using Windows Forms)
PS - Currently I am trying to Bind the code above to a button.
PSS - I used Console Write Line above to keep it simple.

Viewing all articles
Browse latest Browse all 4126

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>