Skip to content

Instantly share code, notes, and snippets.

@KiptoonKipkurui
Created March 21, 2020 14:28
Show Gist options
  • Save KiptoonKipkurui/03aa6a9e4d1f6e83ffe6ce69bac8ade0 to your computer and use it in GitHub Desktop.
Save KiptoonKipkurui/03aa6a9e4d1f6e83ffe6ce69bac8ade0 to your computer and use it in GitHub Desktop.
/// <summary>
/// Gets a user timeline.
/// * API endpoint user_timeline: https://dev.twitter.com/docs/api/1.1/get/statuses/user_timeline
/// </summary>
/// <param name="bearerToken">Token obtained from authentication.</param>
/// <param name="screenName">username of user whose timeline will be returned.</param>
/// <param name="count">Number of tweets to return</param>
/// <param name="excludeReplies">Whether to exclude replies. False is reccomended because API removed replies after obtaining requested number of tweets, leading to unpredictable result counts.</param>
/// <param name="includeRTs">Whether to include retweets. True is reccomended because API removes retweets after obtaining requested number of tweets, leading to unpredictable result counts.(</param>
/// <returns>Raw JSON response from API.</returns>
public async Task<string> GetUserTimelineJson(string bearerToken, string screenName, int count = 10, bool excludeReplies = false, bool includeRTs = true)
{
var webrequest = CreateRequest(
"/1.1/statuses/user_timeline.json"
+ "?screen_name=" + screenName + "&count=" + count + "&exclude_replies=" + excludeReplies.ToString().ToLower() + "&include_rts=" + includeRTs.ToString().ToLower(),HttpMethod.Get);
webrequest.Headers.Add("Authorization", "Bearer " + bearerToken);
return await ReadResponse(webrequest);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment