public TwitterSearchStream(TwitterProtocolManager protocolManager,
                                   GroupChatModel chat, string keyword,
                                   OAuthTokens tokens, WebProxy proxy)
        {
            if (protocolManager == null) {
                throw new ArgumentNullException("protocolManager");
            }
            if (chat == null) {
                throw new ArgumentNullException("chat");
            }
            if (keyword == null) {
                throw new ArgumentNullException("keyword");
            }
            if (tokens == null) {
                throw new ArgumentNullException("tokens");
            }

            ProtocolManager = protocolManager;
            Session = protocolManager.Session;
            Chat = chat;

            var options = new StreamOptions();
            options.Track.Add(keyword);

            Stream = new TwitterStream(tokens, null, options);
            Stream.Proxy = proxy;
            Stream.StartPublicStream(OnStreamStopped, OnStatusCreated, OnStatusDeleted, OnEvent);

            MessageRateLimiter = new RateLimiter(5, TimeSpan.FromSeconds(5));
        }
        public void Start()
        {
            //TileService.Add<TwitterView>(new TileData
            //{
            //    Title = "Peeps",
            //    BackgroundImage = new Uri("pack://siteoforigin:,,,/Resources/Tiles/MB_0005_weather1.png")
            //});

            Task.Factory.StartNew(() =>
            {
                OAuthTokens tokens = new OAuthTokens();
                tokens.AccessToken = "478840940-tgD2Fp5NWXpDPGWyrHTxIjroDODe6F9r8JEkabQ";
                tokens.AccessTokenSecret = "Jo4fgjtkYBPTfyuigi3slqOo7lVer7rLXwj6rWs";
                tokens.ConsumerKey = "O6MTEfpHhHfhnBr4PuVmlw";
                tokens.ConsumerSecret = "lDZgfovK9FEtn8MBsTpGPn8WvuTbGal2yBD4kHLgI";

                StreamOptions options = new StreamOptions();
                Stream = new TwitterStream(tokens, "v1", options);
                Stream.StartUserStream(Friends,
                                       Stopped,
                                       Created,
                                       Deleted,
                                       DirectMessageCreated,
                                       DirectMessageDeleted,
                                       Callback);
                Radio.CurrentTrackChanged += RadioOnCurrentTrackChanged;
            })
            .ContinueWith(task =>
            {
                if (task.Exception != null)
                {
                    Logger.Log(task.Exception.ToString(), Category.Exception, Priority.Medium);
                }
            });
        }
Exemple #3
0
 static void Main(string[] args)
 {
     Console.WriteLine("Enter Queries for the first stream separated by comma:");
     String list = Console.ReadLine();
     string[] query = Regex.Split(list, ",");
     StreamOptions options = new StreamOptions();
     foreach (String q in query)
     {
         options.Track.Add(q);
     }
     startStream(options);
 }
        public override bool OnStart()
        {
            #region base
            // Définissez le nombre maximal de connexions simultanées 
            ServicePointManager.DefaultConnectionLimit = 12;
            #endregion

            tokens = new OAuthTokens()
            {
                ConsumerKey = "REMOVED",
                ConsumerSecret = "REMOVED",
                AccessToken = "REMOVED",
                AccessTokenSecret = "REMOVED"
            };

            options = new StreamOptions();
            options.Track.Add("#travel");
            options.Track.Add("travel");
            options.Track.Add("#plane");
            options.Track.Add("plane");

            stream = new TwitterStream(
                tokens,
                "Demo Jerome CHRIST Twitter Stream Big Data",
                options);

            // Retrieve the storage account ConnectionString from the settings
            storageAccount = CloudStorageAccount.Parse(CloudConfigurationManager.GetSetting("StorageConnectionString"));

            // Create a blob client
            blobClient = storageAccount.CreateCloudBlobClient();

            // Retrieve a reference to a container. 
            container = blobClient.GetContainerReference("socialtravel");


            //// Create or overwrite the blob
            //using (var fileStream = System.IO.File.OpenRead(@"path\myfile"))
            //{
            //    blockBlob.UploadFromStream(fileStream);
            //}

            #region base
            // Pour plus d'informations sur la gestion des modifications de configuration
            // consultez la rubrique MSDN à l'adresse http://go.microsoft.com/fwlink/?LinkId=166357.

            return base.OnStart();
            #endregion

        }
        public void StartCaptureStreaming(string searchkey)
        {
            StreamOptions options = new StreamOptions();
            options.Track.Add(searchkey);

            _stream = new TwitterStream(tokens, "TwitterSky", options);

            _stream.StartPublicStream(
                StreamStopped,
                NewTweet,
                DeletedTweet,
                OtherEvent
            );
        }
Exemple #6
0
        /// <summary>
        /// Twitterストリームを初期化
        /// </summary>
        /// <param name="output">ログ出力用Delegate</param>
        private Twitter(logOutput output = null)
        {
            LogOutput = output;

            if (
                string.IsNullOrWhiteSpace(Properties.Settings.Default.consumerKey) ||
                string.IsNullOrWhiteSpace(Properties.Settings.Default.consumerSecret) ||
                string.IsNullOrWhiteSpace(Properties.Settings.Default.accessToken) ||
                string.IsNullOrWhiteSpace(Properties.Settings.Default.accessTokenSecret)
                )
            {
                OAuthForm f = new OAuthForm();
                if (f.ShowDialog() == System.Windows.Forms.DialogResult.Abort)
                {
                    System.Windows.Forms.Application.Exit();
                    Environment.Exit(0);
                }
                Properties.Settings.Default.Reload();
            }

            token = new OAuthTokens
            {
                ConsumerKey = Properties.Settings.Default.consumerKey,
                ConsumerSecret = Properties.Settings.Default.consumerSecret,
                AccessToken = Properties.Settings.Default.accessToken,
                AccessTokenSecret = Properties.Settings.Default.accessTokenSecret
            };

            ustream = new TwitterStream(token, "labMonitor", null);

            var k = Properties.Settings.Default.Kamatte;
            var opt = new StreamOptions();
            if (k != null)
            {
                opt.Follow = k.GetTargetIdArray();
                opt.Track = k.GetTargetNameArray();
                pstream = new TwitterStream(token, "labMonitorPublic", opt);
            }
        }
        public void StartCaptureStreaming(SearchParameters parameters)
        {
            StreamOptions options = new StreamOptions();
            options.Track.Add(parameters.SearchKey);
            this._stopSearch = false;

            TwitterStream stream = new TwitterStream(tokens, "RTSearch (Dev)", options);

            IAsyncResult result = stream.StartPublicStream(
                StreamStopped,
                NewTweet,
                DeletedTweet,
                OtherEvent
            );

            while (!this._stopSearch)
            {

            }

            stream.EndStream(StopReasons.StoppedByRequest, "Stop by user");
        }
Exemple #8
0
        public void PublicStream(StreamOptions streamOptions, Action<TwitterStream> streamStarted,
			Action<StopReasons> streamErrorCallback,
			Action<TwitterStatus> statusCreatedCallback, Action<TwitterStreamDeletedEvent> statusDeletedCallback,
			Action<TwitterStreamEvent> eventCallback, Action<string> rawJsonCallback = null)
        {
            var stream = new TwitterStream(OAuthTokens, "MeetCurses", streamOptions);
            new Task(() => {
                stream.StartPublicStream((stopreason) => {
                    callbacks.Send(() => streamErrorCallback(stopreason));
                }, (status) => {
                    callbacks.Send(() => statusCreatedCallback(status));
                }, (status) => {
                    callbacks.Send(() => statusDeletedCallback(status));
                }, (twitterStreamEvent) => {
                    callbacks.Send(() => eventCallback(twitterStreamEvent));
                }, (rawJson) => {
                    callbacks.Send(() => {
                        if (rawJsonCallback != null) {
                            rawJsonCallback(rawJson);
                        }
                    });
                });
            }).Start(TaskScheduler);
        }
Exemple #9
0
        public static void startStream(StreamOptions options)
        {
            Console.BufferWidth = 100;
            Console.WindowWidth = 100;

            TwitterStream stream = new TwitterStream(
                tokens,
                "UofCResearch",
                options);

            Console.WriteLine("stream 1 is starting ...");
            stream.StartPublicStream(
                StreamStopped,
                NewTweet,
                DeletedTweet,
                OtherEvent,
                RawJson);

            Console.WriteLine("stream 1 has started. Press any key to stop.");
            Console.ReadKey();

            Console.WriteLine("Stopping the stream ...");
            stream.EndStream();
        }
Exemple #10
0
        public void StartStreaming()
        {
            TwitterIdCollection followingIDs = null; // TODO: This could update mid-session.. NOTE!!!!111oneone (EventCallback maybe?)
              StreamOptions streamOptions = new StreamOptions();

              Global.Streaming = new TwitterStream(Global.requestToken, "", streamOptions);
              // override the default Twitterizer user agent, which is "Twitterizer/<version>", because we're assholes :D
              Global.Streaming.GetType().GetField("userAgent", (System.Reflection.BindingFlags)65535).SetValue(Global.Streaming, "TweetDeck Sucks / 0.01 / [email protected]");

              Global.Streaming.StartUserStream(new InitUserStreamCallback((TwitterIdCollection ee) => {
            followingIDs = ee;
              }), new StreamStoppedCallback((StopReasons stopReason) => {
            Console.WriteLine("StreamStoppedCallback : " + stopReason.ToString());

              }), new StatusCreatedCallback((TwitterStatus tweet) => {
            // if user is following
            if (followingIDs.Contains(tweet.User.Id)) {
              // show in timeline columns
              InsertTweetIn(tweet, ColumnType.Timeline);
            }

            // if user is being mentioned
            if (tweet.Text.ToLower().Contains("@" + Global.ThisUser.ScreenName.ToLower())) {
              // show in mentions columns
              InsertTweetIn(tweet, ColumnType.Mentions);
            }
              }), new StatusDeletedCallback((TwitterStreamDeletedEvent ee) => {
            foreach (ColumnControl cc in flowColumns.Controls) {
              foreach (TweetControl tc in cc.flowColumn.Controls) {
            if (tc.Tweet != null && tc.Tweet.Id == ee.Id) {
              tc.MarkDeleted();
            }
              }
            }
              }), new DirectMessageCreatedCallback((TwitterDirectMessage dm) => {
            InsertDMIn(dm, ColumnType.DirectMessages);
              }), new DirectMessageDeletedCallback((TwitterStreamDeletedEvent ee) => {
            foreach (ColumnControl cc in flowColumns.Controls) {
              foreach (TweetControl tc in cc.flowColumn.Controls) {
            if (tc.DM != null && tc.DM.Id == ee.Id) {
              tc.MarkDeleted();
            }
              }
            }
              }), new EventCallback((TwitterStreamEvent ee) => {
            Console.WriteLine("EventCallback");

              }));
        }
Exemple #11
0
        /// <summary>
        /// Initializes a new instance of the <see cref="TwitterStream"/> class.
        /// </summary>
        /// <param name="tokens">The tokens.</param>
        /// <param name="userAgent">The useragent string which shall include the version of your client.</param>
        /// <param name="streamoptions">The stream or user stream options to intially use when starting the stream.</param>
        public TwitterStream(OAuthTokens tokens, string userAgent, StreamOptions streamoptions)
        {
            #if !SILVERLIGHT // No non-silverlight user-agent as Assembly.GetName() isn't supported and setting the request.UserAgent is also not supported.
            if (string.IsNullOrEmpty(userAgent))
            {
                this.UserAgent = string.Format(
                    CultureInfo.InvariantCulture,
                    "Twitterizer/{0}",
                    System.Reflection.Assembly.GetExecutingAssembly().GetName().Version);
            }
            else
            {
                this.UserAgent = string.Format(
                    CultureInfo.InvariantCulture,
                    "{0} (via Twitterizer/{1})",
                    userAgent,
                    System.Reflection.Assembly.GetExecutingAssembly().GetName().Version);
            }
            #endif
            this.Tokens = tokens;

            if (streamoptions != null)
                this.StreamOptions = streamoptions;
        }
Exemple #12
0
        public void UserStream(StreamOptions streamOptions, Action<TwitterStream> streamStarted, Action<TwitterIdCollection> friendsCallback, Action<StopReasons> streamErrorCallback,
			Action<TwitterStatus> statusCreatedCallback, Action<TwitterStreamDeletedEvent> statusDeletedCallback,
			Action<TwitterDirectMessage> directMessageCreatedCallback, Action<TwitterStreamDeletedEvent> directMessageDeletedCallback,
			Action<TwitterStreamEvent> eventCallback, Action<string> rawJsonCallback = null)
        {
            var stream = new TwitterStream(OAuthTokens, "MeetCurses", streamOptions);
            new Task(() => {
                stream.StartUserStream((friendsId) => {
                    callbacks.Send(() => friendsCallback(friendsId));
                }, (stopreason) => {
                    callbacks.Send(() => streamErrorCallback(stopreason));
                }, (status) => {
                    callbacks.Send(() => statusCreatedCallback(status));
                }, (status) => {
                    callbacks.Send(() => statusDeletedCallback(status));
                }, (status) => {
                    callbacks.Send(() => directMessageCreatedCallback(status));
                }, (status) => {
                    callbacks.Send(() => directMessageDeletedCallback(status));
                }, (twitterStreamEvent) => {
                    callbacks.Send(() => eventCallback(twitterStreamEvent));
                }, (rawJson) => {
                    callbacks.Send(() => {
                        if (rawJsonCallback != null) {
                            rawJsonCallback(rawJson);
                        }
                    });
                });
                callbacks.Send(() => streamStarted(stream));
            }).Start(TaskScheduler);
        }
Exemple #13
0
 public void PublicStream(StreamOptions options, Action<TwitterStream, PublicStreamCallbacks> streamStarted)
 {
     PublicStreamCallbacks callbacks = new PublicStreamCallbacks();
     PublicStream(options, callbacks, (stream) => {
         streamStarted(stream, callbacks);
     });
 }
Exemple #14
0
 public void PublicStream(StreamOptions options, PublicStreamCallbacks callbacks, Action<TwitterStream> streamStarted)
 {
     PublicStream(options, streamStarted, callbacks.OnStreamError,
         callbacks.OnStatusCreated, callbacks.OnStatusDeleted,
         callbacks.OnEvent, callbacks.OnRawJson);
 }
Exemple #15
0
 /// <summary>
 /// Starts UserStream.
 /// </summary>
 /// <param name="friendsCallback">A callback called when UserStream is intialized. This can be null.</param>
 /// <param name="errorCallback">A callback called when UserStream is stopped. This can be null.</param>
 /// <param name="statusCreatedCallback">A callback when receive a new status. This can be null.</param>
 /// <param name="statusDeletedCallback">A callback when a status is deleted. This can be null.</param>
 /// <param name="dmCreatedCallback">A callback when receive a new direct message. This can be null.</param>
 /// <param name="dmDeletedCallback">A callback when a direct message is deleted. This can be null.</param>
 /// <param name="eventCallback">A callback when a new event is raised. This can be null.</param>
 public void StartStreaming(InitUserStreamCallback friendsCallback, StreamStoppedCallback errorCallback,
     StatusCreatedCallback statusCreatedCallback, StatusDeletedCallback statusDeletedCallback,
     DirectMessageCreatedCallback dmCreatedCallback, DirectMessageDeletedCallback dmDeletedCallback,
     EventCallback eventCallback)
 {
     var option = new StreamOptions()
     {
         Count = 0
     };
     stream = new TwitterStream(token, UserAgent, option);
     stream.StartUserStream(friendsCallback, errorCallback, statusCreatedCallback, statusDeletedCallback, dmCreatedCallback, dmDeletedCallback, eventCallback, null);
 }
Exemple #16
0
 public void UserStream(StreamOptions streamOptions, UserStreamCallbacks callbacks, Action<TwitterStream> streamStart)
 {
     UserStream(streamOptions, streamStart,
         callbacks.OnFriends, callbacks.OnStreamError, callbacks.OnStatusCreated,
         callbacks.OnStatusDeleted, callbacks.OnDirectedMessageCreated, callbacks.OnDirectMessageDeleted,
         callbacks.OnEvent, callbacks.OnRawJson);
 }
Exemple #17
0
        private void StartStreaming()
        {
            OAuthTokens tokens = new OAuthTokens() {
                ConsumerKey = OAuthData.ConsumerKey,
                ConsumerSecret = OAuthData.ConsumerSecret,
                AccessToken = OAuthData.AccessToken,
                AccessTokenSecret = OAuthData.AccessTokenSecret
            };

            StreamOptions options = new StreamOptions();

            twitter_streaming = new TwitterStream(tokens, "Twisland Streaming", options);
            twitter_streaming.StartUserStream(
                Init,
                Stop,
                NewTweet,
                DeletedTweet,
                NewDirectMessage,
                DeletedDirectMessage,
                Other);
        }
Exemple #18
0
 public void UserStream(StreamOptions streamOptions, Action<TwitterStream, UserStreamCallbacks> streamStart)
 {
     UserStreamCallbacks callbacks = new UserStreamCallbacks();
     UserStream(streamOptions, callbacks, (stream) => {
         streamStart(stream, callbacks);
     });
 }
Exemple #19
0
		public ColumnEditer(Dictionary<string, ExtendedOAuthTokens> oaus)
		{
			o = oaus;
			InitializeComponent();
			opt = new StreamOptions();
		}
        private void StartStreamListener()
        {
            // Starts listening on the Twitter streaming API
            StreamOptions options = new StreamOptions();
            TwitterStream stream = new TwitterStream(Tokens, "StudentRND Twitter Door Lock 2.0 (THE DOOOOOOOOOR)", options);

            stream.StartUserStream(null, new StreamStoppedCallback(delegate(StopReasons ex)
            {
                // Sometimes the Twitter streaming API will kill the stream

                // Log the failure:
                MainForm.Instance.logControl.Add("Twitter stream stopped: " + ex.ToString(), LogEntryType.Error);
                Thread.Sleep(5000);

                // Restart the stream
                StartStreamListener();
            }), new StatusCreatedCallback(ProcessNewStatus), null, null, null, null, null);
        }