Beispiel #1
0
        static void Rotina(Object o)
        {
            try
            {
                Auth.SetUserCredentials("CONSUMER_KEY", "CONSUMER_SECRET", "ACCESS_TOKEN", "ACCESS_TOKEN_SECRET");

                // Get json directly
                var tweetsJson = SearchJson.SearchTweets("MINHA_PALAVRA_CHAVE");

                // Get json from ITweet objects
                var tweets = Search.SearchTweets("testetadepe");
                // JSON Convert from Newtonsoft available with Tweetinvi
                var json = JsonConvert.SerializeObject(tweets.Select(x => x.TweetDTO));
                var tweetDTOsFromJson = JsonConvert.DeserializeObject <ITweetDTO[]>(json, JsonPropertiesConverterRepository.Converters);
                var tweetsFromJson    = Tweet.GenerateTweetsFromDTO(tweetDTOsFromJson);

                foreach (ITweetDTO tw in tweetDTOsFromJson)
                {
                    DataTable tabela = RetornaTabela("SELECT * FROM TWEET WHERE ID=" + tw.Id.ToString());

                    string id   = tw.Id.ToString();
                    string user = tw.CreatedBy.ToString();

                    if (tabela.Rows.Count == 0)
                    {
                        InsereTweet(id, user);

                        Tweet.PublishTweet("@" + tw.CreatedBy + " Olá, meu nome é Liza, tudo bem? Você sabia que  pode fazer sua reclamação comigo através deste link?  https://m.me/FiscalizaObra  #" + id.ToString());
                    }
                }
            }
            catch
            {
            }
        }
        private void UpdateTweets()
        {
            string tweetFeedInJson = SearchJson.SearchTweets("dotnetconfsg");

            var tweetFeed = JsonConvert.DeserializeObject <TweetFeed>(tweetFeedInJson);

            this.DataContext = new Tweets(tweetFeed, isShowingAllTweets);
        }
Beispiel #3
0
        static void Main(string[] args)
        {
            Console.WriteLine("Connecting to twitter.com...");
            var jsonResult = SearchJson.SearchTweets("tweetinvi");

            TwitterCredentials.CreateCredentials("490599333-RkRqjA4Icbh0PVyQdllZyoD0Y2S6Cjc5F2eo6Tb6", "727vXKJyQ7bGoTjDNI3gJR5gJ4OUShsJhazaYDDkqs6jt", "XT6Xu6sNxnBxeDODPIawUA", "rI1aWSVDcNN4XnmUofkkaIvbzhTivkL0HSeonleDeZY");
            Console.WriteLine(ExceptionHandler.GetLastException().StatusCode);
            Console.WriteLine(ExceptionHandler.GetLastException().TwitterDescription);
            Console.WriteLine(ExceptionHandler.GetLastException().TwitterExceptionInfos.First().Message);
            Console.ReadKey();
        }
        public static void Search_SimpleTweetSearch()
        {
            var searchParameter = Search.CreateTweetSearchParameter("@timesnow");

            searchParameter.MaximumNumberOfResults = 0000;
            var tweets = SearchJson.SearchTweets(searchParameter);

            System.IO.StreamWriter file = new System.IO.StreamWriter("timesnow.json", true);
            foreach (var tweet in tweets)
            {
                String replacedString  = tweet.Replace("{\"statuses\":[", "");
                string replacedString2 = replacedString.Replace("},{\"metadata\":", "}\n{\"metadata\":");
                string removedString   = replacedString2.Remove(replacedString2.IndexOf("],\"search_metadata"));
                file.WriteLine(removedString);
                file.Flush();
            }
            file.Close();
        }