简体   繁体   中英

Saving tweets via Streaming using Twitter API c#

hi i would like to save my tweets into a text file but am unsure of how to so.

here is my code for streaming:

                (from strm in twitterCtx.Streaming.WithCancellation(cancelTokenSrc.Token)
                 where strm.Type == StreamingType.Filter &&
                       strm.Track == searchTerm
                 select strm)
                .StartAsync(async strm =>
                {
                    HandleStreamResponse(strm);


                    if (count++ >= 600)
                       cancelTokenSrc.Cancel();

                });

This is how i output the result:

var status = strm.Entity as Status;

                Console.WriteLine("Status-({3}) ({2}) @{0}: {1}", status.User.ScreenNameResponse, status.Text, status.CreatedAt, status.User.Location);

                Console.WriteLine("");
                break;

You might want to take a look at the MSDN documentation for File.AppendText located at https://msdn.microsoft.com/en-us/library/system.io.file.appendtext.aspx

The page includes an example of how to write text to a file.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM