本文整理汇总了C#中TwitterService.GetUserTimeline方法的典型用法代码示例。如果您正苦于以下问题:C# TwitterService.GetUserTimeline方法的具体用法?C# TwitterService.GetUserTimeline怎么用?C# TwitterService.GetUserTimeline使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TwitterService
的用法示例。
在下文中一共展示了TwitterService.GetUserTimeline方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main(string[] args)
{
var consumerKey = ConfigurationManager.AppSettings["consumerKey"];
if (string.IsNullOrEmpty(consumerKey))
{
Console.Write("Enter the consumer key: ");
consumerKey = Console.ReadLine();
}
var consumerSecret = ConfigurationManager.AppSettings["consumerSecret"];
if (string.IsNullOrEmpty(consumerSecret))
{
Console.Write("Enter the consumer secret: ");
consumerSecret = Console.ReadLine();
}
Console.Write("Enter the desired screen name: ");
var screenName = Console.ReadLine();
Console.Write("Enter how many tweets to retrieve: ");
var numberOfTweets = int.Parse(Console.ReadLine() ?? "");
Console.WriteLine("Retrieving user timeline...");
var auth = new ApplicationOnlyAuth(consumerKey, consumerSecret);
var service = new TwitterService(auth);
var timeline = service.GetUserTimeline(screenName, numberOfTweets);
foreach (var tweet in timeline.Tweets)
{
Console.WriteLine();
Console.WriteLine("{0:MM-dd-yyyy HH:mm:ss} : {1}", tweet.Created, tweet.Text);
Console.WriteLine("Retweeted {0} time, favorited {1} times", tweet.RetweetCount.GetValueOrDefault(0),
tweet.FavoriteCount.GetValueOrDefault(0));
}
Console.Write("Press any key to exit...");
Console.ReadLine();
}