forked from swhitley/TwitterStreamClient
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSampleProgram.cs
More file actions
49 lines (39 loc) · 1.23 KB
/
SampleProgram.cs
File metadata and controls
49 lines (39 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
using System;
namespace TwitterStreamClient
{
public class SampleProgram
{
static string user = "user";
static string pass = "pass";
static bool isEncrypted = false;
static int numberOfTweets = 10;
static void Main (string[] args)
{
// create a string with your credentials
// if you provide an encrypted password, set the flag
TwitterStream stream = new TwitterStream (user, pass, isEncrypted);
/*
// Optional: Add a filter. If filtering,
// the Twitter API requires to specify at least 1 parameter
TwitterStreamFilter filter = new TwitterStreamFilter ();
string[] keywords = { "twitter", "pizza"};
filter.setTrackingKeywords (keywords);
// to remove the filter, set it to null
stream.SetStreamFilter (filter);
*/
stream.StartAsyncStream ();
while (stream.IsStreamRunning() && (numberOfTweets != 0)) {
Status status = stream.GetBlockingNextStatus ();
// make sure to handle deleted statuses which appear in
// public stream
if (status.text != null) {
Console.Write ("@" + status.user.screen_name + ": ");
Console.WriteLine (status.text);
numberOfTweets--;
}
}
// make sure to clean up
stream.StopAsyncStream ();
}
}
}