本文整理汇总了C#中TwitterService.ListTweetsOnPublicTimeline方法的典型用法代码示例。如果您正苦于以下问题:C# TwitterService.ListTweetsOnPublicTimeline方法的具体用法?C# TwitterService.ListTweetsOnPublicTimeline怎么用?C# TwitterService.ListTweetsOnPublicTimeline使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TwitterService
的用法示例。
在下文中一共展示了TwitterService.ListTweetsOnPublicTimeline方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Can_get_public_timeline
public void Can_get_public_timeline()
{
var service = new TwitterService();
var tweets = service.ListTweetsOnPublicTimeline();
Assert.IsNotNull(tweets);
Assert.AreEqual(20, tweets.Count());
Assert.IsNotNull(service.Response);
Assert.AreEqual(HttpStatusCode.OK, service.Response.StatusCode);
var unfavorited = 20;
foreach (var tweet in tweets)
{
Assert.IsNotNullOrEmpty(tweet.RawSource);
Assert.AreNotEqual(default(DateTime), tweet.CreatedDate);
Console.WriteLine("{0} said '{1}'", tweet.User.ScreenName, tweet.Text);
if(tweet.IsFavorited)
{
unfavorited--;
}
}
Assert.IsTrue(unfavorited > 0);
AssertRateLimitStatus(service);
}
示例2: Can_get_public_timeline_async_callback_style
public void Can_get_public_timeline_async_callback_style()
{
var service = new TwitterService();
var result = service.ListTweetsOnPublicTimeline(
(tweets, response) =>
{
Assert.AreEqual(HttpStatusCode.OK, response.StatusCode);
Assert.IsNotNull(tweets);
Assert.AreEqual(20, tweets.Count());
foreach (var tweet in tweets)
{
Console.WriteLine("{0} said '{1}'", tweet.User.ScreenName, tweet.Text);
}
});
result.AsyncWaitHandle.WaitOne(TimeSpan.FromSeconds(5));
}
示例3: Can_coalesce_entities_on_timeline
public void Can_coalesce_entities_on_timeline()
{
var service = new TwitterService();
var tweets = service.ListTweetsOnPublicTimeline();
var passed = false;
foreach(var tweet in tweets)
{
if(tweet.Entities == null)
{
continue;
}
var entities = tweet.Entities.Coalesce();
if(entities.Count() < 2)
{
continue;
}
var previous = -1;
foreach(var entity in entities)
{
Assert.IsTrue(previous < entity.StartIndex);
previous = entity.StartIndex;
}
passed = true;
}
if(!passed)
{
Assert.Ignore("This test pass yielded no entities with both a hashtag and a URL.");
}
}
示例4: Can_get_entities_on_timeline
public void Can_get_entities_on_timeline()
{
var service = new TwitterService();
var tweets = service.ListTweetsOnPublicTimeline();
foreach (var tweet in tweets)
{
Assert.IsNotNull(tweet.Entities);
if (tweet.Entities.HashTags.Count() > 0)
{
foreach (var hashtag in tweet.Entities.HashTags)
{
Assert.IsNotNullOrEmpty(hashtag.Text);
}
}
if (tweet.Entities.Urls.Count() > 0)
{
foreach (var url in tweet.Entities.Urls)
{
Assert.IsNotNullOrEmpty(url.Value);
}
}
if (tweet.Entities.Mentions.Count() > 0)
{
foreach (var mention in tweet.Entities.Mentions)
{
Assert.IsNotNullOrEmpty(mention.ScreenName);
}
}
}
}
示例5: Can_avoid_entities_on_timeline
public void Can_avoid_entities_on_timeline()
{
var service = new TwitterService { IncludeEntities = false };
var tweets = service.ListTweetsOnPublicTimeline();
foreach(var tweet in tweets)
{
Assert.IsNull(tweet.Entities);
}
}
示例6: Can_use_xml_internally
public void Can_use_xml_internally()
{
var service = new TwitterService { Format = TwitterServiceFormat.Xml };
var tweets = service.ListTweetsOnPublicTimeline();
Assert.IsNotNull(tweets);
Assert.AreEqual(20, tweets.Count());
foreach (var tweet in tweets)
{
Assert.IsNotNull(tweet.RawSource);
Console.WriteLine("{0}[{1} says '{2}", tweet.User.ScreenName, tweet.Id, tweet.Text);
}
}
示例7: Can_deserialize_dates
public void Can_deserialize_dates()
{
var service = new TwitterService();
var tweets = service.ListTweetsOnPublicTimeline();
Assert.IsNotNull(tweets);
Assert.AreEqual(20, tweets.Count());
foreach (var tweet in tweets)
{
Console.WriteLine("{0} said '{1}'", tweet.User.ScreenName, tweet.Id);
Assert.AreNotEqual(default(DateTime), tweet.CreatedDate);
}
}