Exemplo n.º 1
0
        public void TestSearchTweets()
        {
            var oAuthTwitterWrapper = new OAuthTwitterWrapper.OAuthTwitterWrapper();
            var result = JsonConvert.DeserializeObject <Search>(oAuthTwitterWrapper.GetSearch());

            Assert.IsTrue(result.Results.Count > 0);
        }
Exemplo n.º 2
0
        public void TestTwitterAuthentication()
        {
            var oAuthTwitterWrapper = new OAuthTwitterWrapper.OAuthTwitterWrapper();
            var result = JsonConvert.DeserializeObject <Search>(oAuthTwitterWrapper.GetSearch());

            Assert.IsNotNull(result);
        }
Exemplo n.º 3
0
        public string ProcessRequest()
        {
            var responseString = "";
            try
            {
                //MapRequestParamsToConfigs();
                var oAuthTwitterWrapper = new OAuthTwitterWrapper.OAuthTwitterWrapper(_authconfig, _twitConfig);

                switch (HttpContext.Current.Request["url"])
                {
                    case "search":
                        responseString = oAuthTwitterWrapper.GetSearch();
                        break;
                    case "list":
                        responseString = oAuthTwitterWrapper.GetStatusList();
                        break;
                    default:
                        responseString = oAuthTwitterWrapper.GetMyTimeline();
                        break;
                }
            }
            catch (Exception)
            {

            }

            return responseString;
        }
Exemplo n.º 4
0
        static void Main(string[] args)
        {
            var oAuthTwitterWrapper = new OAuthTwitterWrapper.OAuthTwitterWrapper();
            var result = JsonConvert.DeserializeObject <Search>(oAuthTwitterWrapper.GetSearch());

            SaveTweets(result.Results);
        }
Exemplo n.º 5
0
        public void printHits()
        {
            var oAuthTwitterWrapper = new OAuthTwitterWrapper.OAuthTwitterWrapper();

            Console.Write("**** Time Line *****\n");
            Console.Write(oAuthTwitterWrapper.GetMyTimeline() + "\n\n");
            Console.Write("**** Search *****\n");
            Console.Write(oAuthTwitterWrapper.GetSearch() + "\n\n");
            //oAuthTwitterWrapper.TimeLineSettings = new TimeLineSettings {
            Console.ReadLine();
        }
        public object Get(string url, string screen_name, string include_rts, string exclude_replies, string q = null, string list_id = null, int count = 20)
        {
            //var oauthAccessToken = ConfigurationManager.AppSettings[Constants.TwitterOAuthAccessToken];
            //var oauthAccessTokenSecret = ConfigurationManager.AppSettings[Constants.TwitterOAuthAccessTokenSecret];

            var authSettings = new OAuthTwitterWrapper.AuthenticateSettings()
            {
                OAuthConsumerKey = ConfigurationManager.AppSettings[Constants.TwitterConsumerKey],
                OAuthConsumerSecret = ConfigurationManager.AppSettings[Constants.TwitterConsumerSecret],
                OAuthUrl = "https://api.twitter.com/oauth2/token"
            };
            var searchSettings = new OAuthTwitterWrapper.SearchSettings()
            {
              SearchFormat = "https://api.twitter.com/1.1/{0}"
            };
            var timelineSettings = new OAuthTwitterWrapper.TimeLineSettings();

            switch (url)
            {
                case "timeline":
                    searchSettings.SearchQuery = $"statuses/user_timeline.json?screen_name={screen_name}&amp;include_rts={include_rts}&amp;exclude_replies={exclude_replies}&amp;count={count}";
                    break;

                case "search":
                    searchSettings.SearchQuery = $"search/tweets.json?q={q}&amp;include_rts={include_rts}&amp;count={count}";
                    break;

                case "list":
                    searchSettings.SearchQuery = $"lists/statuses.json?list_id={list_id}&amp;include_rts={include_rts}&amp;count={count}";
                    break;

                default:
                    searchSettings.SearchQuery = $"statuses/user_timeline.json?count={count}";
                    break;
            }

            var twit = new OAuthTwitterWrapper.OAuthTwitterWrapper(authSettings, timelineSettings, searchSettings);
            var json = twit.GetSearch();

            var response = new HttpResponseMessage(HttpStatusCode.OK);
            response.Content = new StringContent(json);
            response.Content.Headers.ContentType = new MediaTypeHeaderValue("application/json");
            return response;
        }
Exemplo n.º 7
0
        static void Main(string[] args)
        {
            var oAuth = new OAuthConfiguration()
                            {
                                ConsumerToken = "GPdZTjmPRVXP2cgYgjMQ",
                                ConsumerSecret = "LDh41edDBODdRXrvfAjaK5niYGjiaLilaSPDPYOH6LI",
                                AuthUrl = "https://api.twitter.com/oauth2/token"
                            };
            var twitconfig = new TwitterConfiguration()
                                 {
                                     ScreenName = "freshupdates"
                                 };

            var oAuthTwitterWrapper = new OAuthTwitterWrapper.OAuthTwitterWrapper(oAuth,twitconfig);
            Console.Write("**** Time Line *****\n");
            Console.Write(oAuthTwitterWrapper.GetMyTimeline() + "\n\n");
            Console.Write("**** Search *****\n");
            Console.Write(oAuthTwitterWrapper.GetSearch() + "\n\n");
            Console.ReadLine();
        }