本文整理汇总了C#中TwitterService.ListDirectMessagesSent方法的典型用法代码示例。如果您正苦于以下问题:C# TwitterService.ListDirectMessagesSent方法的具体用法?C# TwitterService.ListDirectMessagesSent怎么用?C# TwitterService.ListDirectMessagesSent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TwitterService
的用法示例。
在下文中一共展示了TwitterService.ListDirectMessagesSent方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Can_get_entities_on_direct_messages
public void Can_get_entities_on_direct_messages()
{
var service = new TwitterService { IncludeEntities = true };
service.AuthenticateWith(_consumerKey, _consumerSecret, _accessToken, _accessTokenSecret);
var tweets = service.ListDirectMessagesSent(new ListDirectMessagesSentOptions());
if(!tweets.Any())
{
Assert.Ignore("No direct messages available to verify entities");
}
Console.WriteLine(service.Response.Response);
foreach (var tweet in tweets)
{
Assert.IsNotNull(tweet.Entities);
var coalesced = tweet.Entities.Coalesce();
var text = tweet.Text;
Assert.IsNotNull(tweet.TextAsHtml);
Console.WriteLine("Tweet: " + text);
Console.WriteLine("HTML: " + tweet.TextAsHtml);
foreach(var entity in coalesced)
{
switch(entity.EntityType)
{
case TwitterEntityType.HashTag:
var hashtag = ((TwitterHashTag) entity).Text;
Console.WriteLine(hashtag);
var hashtagText = text.Substring(entity.StartIndex, entity.EndIndex - entity.StartIndex);
Assert.AreEqual("#" + hashtag, hashtagText);
break;
case TwitterEntityType.Mention:
var mention = ((TwitterMention) entity).ScreenName;
Console.WriteLine(mention);
var mentionText = text.Substring(entity.StartIndex, entity.EndIndex - entity.StartIndex);
Assert.AreEqual("@" + mention, mentionText);
break;
case TwitterEntityType.Url:
var url = ((TwitterUrl) entity).Value;
Console.WriteLine(url);
var urlText = text.Substring(entity.StartIndex, entity.EndIndex - entity.StartIndex);
Assert.AreEqual(url, urlText);
break;
default:
throw new ArgumentOutOfRangeException();
}
}
Console.WriteLine();
}
}