本文整理汇总了C#中TweetSharp.TwitterService.ListDirectMessagesReceived方法的典型用法代码示例。如果您正苦于以下问题:C# TwitterService.ListDirectMessagesReceived方法的具体用法?C# TwitterService.ListDirectMessagesReceived怎么用?C# TwitterService.ListDirectMessagesReceived使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TweetSharp.TwitterService
的用法示例。
在下文中一共展示了TwitterService.ListDirectMessagesReceived方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Load
protected void Load(TwitterResource resource)
{
var service = new TwitterService(SensitiveData.ConsumerToken, SensitiveData.ConsumerSecret, resource.User.Key, resource.User.Secret);
switch (resource.Type)
{
case ResourceType.Home:
service.ListTweetsOnHomeTimeline(new ListTweetsOnHomeTimelineOptions { Count = 1, IncludeEntities = true }, (status, response) => ReceiveTweetable(status.Cast<ITweetable>(), response, resource));
break;
case ResourceType.Mentions:
service.ListTweetsMentioningMe(new ListTweetsMentioningMeOptions { Count = 1, IncludeEntities = true }, (status, response) => ReceiveTweetable(status.Cast<ITweetable>(), response, resource));
break;
case ResourceType.Messages:
service.ListDirectMessagesReceived(new ListDirectMessagesReceivedOptions { Count = 1 }, (status, response) => ReceiveTweetable(status.Cast<ITweetable>(), response, resource));
break;
case ResourceType.Favorites:
service.ListFavoriteTweets(new ListFavoriteTweetsOptions { Count = 1 }, (status, response) => ReceiveTweetable(status.Cast<ITweetable>(), response, resource));
break;
case ResourceType.List:
service.ListTweetsOnList(new ListTweetsOnListOptions
{
IncludeRts = false,
Count = 1,
OwnerScreenName = resource.Data.Substring(1, resource.Data.IndexOf('/') - 1),
Slug = resource.Data.Substring(resource.Data.IndexOf('/') + 1)
}, (status, response) => ReceiveTweetable(status.Cast<ITweetable>(), response, resource));
break;
case ResourceType.Search:
service.Search(new SearchOptions { Count = 1, IncludeEntities = true, Q = resource.Data }, (status, response) => ReceiveTweetable(status.Statuses.Cast<ITweetable>(), response, resource));
break;
case ResourceType.Tweets:
service.ListTweetsOnUserTimeline(new ListTweetsOnUserTimelineOptions { Count = 1, ScreenName = resource.Data, IncludeRts = true }, (status, response) => ReceiveTweetable(status.Cast<ITweetable>(), response, resource));
break;
}
}
示例2: appbar_button1_Click
//.........这里部分代码省略.........
tv.name = tweet.User.ScreenName;
tv.thumb_img = tweet.User.ProfileImageUrl;
tv.text = tweet.Text + "\n";
if (tsp.Days > 0)
tv.time = tsp.Days + "일 전";
else if (tsp.Hours > 0)
tv.time = tsp.Hours + "시간 전";
else
tv.time = tsp.Minutes + "분 전";
lists.Add(tv);
}
Dispatcher.BeginInvoke(delegate()
{
if (lists.Count > 0)
{
loadtext.Visibility = Visibility.Collapsed;
pgbar.Visibility = Visibility.Collapsed;
listdata2.ItemsSource = lists;
listdata2.Visibility = Visibility.Visible;
}
else
{
pgbar.Visibility = Visibility.Collapsed;
loadtext.Text = "No items";
}
});
}
});
}
else if (header == "messages")
{
service.ListDirectMessagesReceived(40,
(tweets, response) =>
{
if (response.StatusCode == HttpStatusCode.OK)
{
DateTime ti = DateTime.Now;
DateTime now = ti.ToUniversalTime();
lists = new List<Tweet>();
foreach (var tweet in tweets)
{
Tweet tv = new Tweet();
TimeSpan tsp = now - tweet.CreatedDate;
tv.id = tweet.Id;
tv.name = tweet.Sender.ScreenName;
tv.thumb_img = tweet.Sender.ProfileImageUrl;
tv.text = tweet.Text + "\n";
if (tsp.Days > 0)
tv.time = tsp.Days + "일 전";
else if (tsp.Hours > 0)
tv.time = tsp.Hours + "시간 전";
else
tv.time = tsp.Minutes + "분 전";
lists.Add(tv);
}
Dispatcher.BeginInvoke(delegate()
{
if (lists.Count > 0)
{
loadtext.Visibility = Visibility.Collapsed;
pgbar.Visibility = Visibility.Collapsed;
listdata3.ItemsSource = lists;
listdata3.Visibility = Visibility.Visible;
示例3: GetDirectMessages
public IEnumerable<ChannelMessageHeader> GetDirectMessages()
{
var service = new TwitterService(ChannelHelper.ConsumerKey, ChannelHelper.ConsumerSecret, ChannelHelper.Token, ChannelHelper.TokenSecret);
var result = service.ListDirectMessagesReceived().Union(service.ListDirectMessagesSent());
foreach (var dm in result)
{
yield return new ChannelMessageHeader
{
MessageIdentifier = dm.Id.ToString(),
MessageNumber = dm.Id.ToString(),
Context = String.Format("DM from {0}", dm.Sender.Name),
From = new SourceAddress(dm.Sender.Id.ToString(), dm.Sender.Name),
Body = dm.TextAsHtml,
DateReceived = dm.CreatedDate.ToLocalTime()
};
}
}
示例4: Load
protected void Load(TwitterResource resource)
{
var service = new TwitterService(SensitiveData.ConsumerToken, SensitiveData.ConsumerSecret, resource.User.Key, resource.User.Secret);
switch (resource.Type)
{
case ResourceType.Home:
service.ListTweetsOnHomeTimeline(1, (status, response) => ReceiveTweetable(status.Cast<ITweetable>(), response, resource));
break;
case ResourceType.Mentions:
service.ListTweetsMentioningMe(1, (status, response) => ReceiveTweetable(status.Cast<ITweetable>(), response, resource));
break;
case ResourceType.Messages:
service.ListDirectMessagesReceived(1, (status, response) => ReceiveTweetable(status.Cast<ITweetable>(), response, resource));
break;
case ResourceType.Favorites:
service.ListFavoriteTweets((status, response) => ReceiveTweetable(status.Cast<ITweetable>(), response, resource));
break;
case ResourceType.List:
service.ListTweetsOnList(resource.Data.Substring(1, resource.Data.IndexOf('/') - 1),
resource.Data.Substring(resource.Data.IndexOf('/') + 1), 1, (status, response) => ReceiveTweetable(status.Cast<ITweetable>(), response, resource));
break;
case ResourceType.Search:
service.Search(resource.Data, 1, 20, (status, response) => ReceiveTweetable(status.Statuses.Cast<ITweetable>(), response, resource));
break;
case ResourceType.Tweets:
service.ListTweetsOnSpecifiedUserTimeline(resource.Data, 1, true, (status, response) => ReceiveTweetable(status.Cast<ITweetable>(), response, resource));
break;
}
}