Ejemplo n.º 1
0
        public JsonResult GetTweets(string Symbol)
        {
            TwitLib.Twit t      = new TwitLib.Twit();
            string       bToken = t.GetAuthToken();

            TwitLib.TweetResponse response =
                t.GetTweets(bToken, "$" + Symbol);

            return(Json(response.statuses, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 2
0
        public TweetResponse GetTweets(string BearerToken, string searchTerm)
        {
            string urlToken = "https://api.twitter.com/1.1/search/tweets.json?q=" + searchTerm;

            HttpWebRequest req = (HttpWebRequest)WebRequest.Create(new Uri(urlToken));

            req.Headers.Add("Authorization", "Bearer " + BearerToken);
            req.Method = "GET";

            WebResponse response = req.GetResponse();

            string jsonResponse = "";

            using (var reader = new StreamReader(response.GetResponseStream()))
            {
                jsonResponse = reader.ReadToEnd();
            }

            TweetResponse tweets =
                Newtonsoft.Json.JsonConvert.DeserializeObject <TweetResponse>(jsonResponse);

            return(tweets);
        }