/// <summary> /// Gets user credentials from the session, /// makes the search on Twitter and formats the respond in jsonp /// </summary> public void Search() { try { string jsonpCallback = Request.QueryString["callback"]; if (jsonpCallback == null) { throw new Exception(); } var userCreds = (ITwitterCredentials)Session[SK.User]; if (userCreds == null) { throw new Exception(); } string url = tweetSearchUrl + Request.Url.Query; var userJson = Auth.ExecuteOperationWithCredentials(userCreds, () => { return(TwitterAccessor.ExecuteJsonGETQuery(url)); }); this.jsonpResponseFormatter(Response, userJson); } catch (Exception) { this.jsonpResponseFormatter(Response, "", new { }); } }
/* * SUMMARY: # There are a lot of different methods in this controller # Eventually they need to be better broken out # But for now, the best two methods to use are: # 1) GetListOfITweetsInJToken # 2) GetListOfAllTweetsFullTextInJToken */ #region TWITTER USER ------------------------------------------------------------ // STATUS [ June 24, 2019 ]: not sure if needed or if it works // GetJsonStringOfAllUsersTweetObjects("Buster_ESPN"); public string GetJsonStringOfAllUsersTweetObjects(string screenName) { var stringOfAllJson = TwitterAccessor.ExecuteGETQueryReturningJson($"{ApiUriBase}{ScreenNameSearchType}{screenName}"); Console.WriteLine(stringOfAllJson); return(stringOfAllJson); }
public List <TwitterObject> GetTwitter(string param) { string url = $"https://api.twitter.com/1.1/search/tweets.json?q={param}&result_type=recent&tweet_mode=extended&count=100"; Auth.SetUserCredentials(ConfigurationManager.AppSettings["CustomerKey"], ConfigurationManager.AppSettings["CustomerKeySecret"], ConfigurationManager.AppSettings["AcessToken"], ConfigurationManager.AppSettings["AcessTokenSecret"]); var results = TwitterAccessor.GetQueryableJsonObjectFromGETQuery(url).ToString(); TwitterData twitterData = JsonConvert.DeserializeObject <TwitterData>(results); return(twitterData.twitterData.FindAll(x => x.retweeted == null)); }
// STATUS [ June 24, 2019 ]: this works /// <summary> /// Gets JObject with all tweet info(i.e., text from tweet) from Twitter list based on searchString /// </summary> /// <remarks> /// Uses tweetinvi to execute the search /// Uses 'CreateSearchStringToSearchListFor' to generate search string within method /// Used within 'GetJTokenOfAllTweetTextInJObject' method /// See: https://github.com/linvi/tweetinvi/wiki/Custom-Queries /// </remarks> /// <param name="screenName"> /// The screen name / Twitter handle / user name that you want /// </param> /// <param name="listName"> /// The name of the list as defined by the user (e.g., 'Baseball') /// </param> /// <param name="searchString"> /// The term or terms that you want to search for /// </param> /// <param name="numberOfResultsToReturn"> /// The number of tweets you want returned /// </param> /// <example> /// JObject jsonObject = GetJObjectOfTweetsFromListFiltered("mr_baseball", "baseball", "mookie", 100); /// </example> /// <returns> /// JObject /// </returns> public JObject GetJObjectOfTweetsFromListFiltered(string screenName, string listName, string searchString, int numberOfResultsToReturn) { TweetinviConfig.CurrentThreadSettings.TweetMode = TweetMode.Extended; string fullSearchString = CreateSearchStringToSearchListFor( screenName, listName, searchString, numberOfResultsToReturn ); JObject jsonObject = TwitterAccessor.GetQueryableJsonObjectFromGETQuery(fullSearchString); return(jsonObject); }
// STATUS [ June 24, 2019 ]: this works /// <summary> /// Gets an IEnumerable of twitter ids for all followers of a user /// </summary> /// <remarks> /// Uses tweetinvi to get the user ids /// https://github.com/linvi/tweetinvi/wiki/Custom-Queries /// </remarks> /// <param name="screenName"> /// The screen name / Twitter handle / user name that you want /// </param> /// <example> /// var userIds = GetUserIdsForFollowersOfUser("Buster_ESPN"); /// </example> /// <returns> /// IEnumerable of user ids for Twitter users /// </returns> public IEnumerable <long> GetUserIdsForFollowersOfUser(string screenName) { IEnumerable <long> userIds = TwitterAccessor.ExecuteCursorGETQuery <long, IIdsCursorQueryResultDTO>($"https://api.twitter.com/1.1/followers/ids.json?screen_name={screenName}"); return(userIds); }
// STATUS [ June 24, 2019 ]: this works /// <summary> /// Get a IUserDTO from screen name / Twitter handle / user name /// </summary> /// <remarks> /// Uses tweetinvi to get the user /// https://github.com/linvi/tweetinvi/wiki/Custom-Queries /// </remarks> /// <param name="screenName"> /// The screen name / Twitter handle / user name that you want /// </param> /// <example> /// var iUserDto = GetUserDTO("mr_baseball"); /// </example> /// <returns> /// Tweetinvi.Models.DTO.IUserDTO /// </returns> public IUserDTO GetUserDTO(string screenName) { IUserDTO userDTO = TwitterAccessor.ExecuteGETQuery <IUserDTO>($"https://api.twitter.com/1.1/users/show.json?screen_name={screenName}"); return(userDTO); }