Twitter-API-v2-sample-code icon indicating copy to clipboard operation
Twitter-API-v2-sample-code copied to clipboard

Add C# examples

Open JannemanDev opened this issue 3 years ago • 3 comments

Would be great if there would be examples in C#.

JannemanDev avatar Dec 17 '21 16:12 JannemanDev

We agree! Happy to consider contributions, here.

andypiper avatar Dec 17 '21 18:12 andypiper

Well after a day struggling I managed to get it working and like always it was pretty simple :)

using (var client = new WebClient())
{
    client.Headers[HttpRequestHeader.Authorization] = $"Bearer {settings.Twitter.BearerToken}";
    client.OpenReadCompleted += (sender, e) =>
    {
        using (var reader = new StreamReader(e.Result))
        {
            while (!reader.EndOfStream)
            {
                Console.WriteLine(reader.ReadLine());
            }
        }
    };
    client.OpenReadAsync(new Uri(settings.Twitter.FilteredStreamUrl.AbsoluteUri));
}

JannemanDev avatar Dec 18 '21 22:12 JannemanDev

I'd love to add some C#. I'll see what I can do 👍

mathcodes avatar Apr 21 '23 09:04 mathcodes