本文整理汇总了C#中LinqToTwitter.TwitterContext.NewDirectMessageAsync方法的典型用法代码示例。如果您正苦于以下问题:C# TwitterContext.NewDirectMessageAsync方法的具体用法?C# TwitterContext.NewDirectMessageAsync怎么用?C# TwitterContext.NewDirectMessageAsync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LinqToTwitter.TwitterContext
的用法示例。
在下文中一共展示了TwitterContext.NewDirectMessageAsync方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: NewLongDirectMessageAsync
static async Task NewLongDirectMessageAsync(TwitterContext twitterCtx)
{
string messageOver140Characters =
string.Join("-", Enumerable.Repeat("XXXX", 35)) + " - " + DateTime.Now;
DirectMessage message =
await twitterCtx.NewDirectMessageAsync("Linq2Twitr", messageOver140Characters);
DirectMessage dmResponse =
await
(from dm in twitterCtx.DirectMessage
where dm.Type == DirectMessageType.Show &&
dm.ID == message.IDResponse &&
dm.FullText == true // required for full text, otherwise text truncates to 140
select dm)
.SingleOrDefaultAsync();
if (dmResponse != null &&
dmResponse.Recipient != null &&
dmResponse.Sender != null)
{
Console.WriteLine(
"From: {0}\nTo: {1}\nMessage: {2}",
dmResponse.Sender.Name,
dmResponse.Recipient.Name,
dmResponse.Text);
}
}
示例2: NewDirectMessageAsync
static async Task NewDirectMessageAsync(TwitterContext twitterCtx)
{
DirectMessage message = await twitterCtx.NewDirectMessageAsync(
"Linq2Twitr", "Direct Message Test - " + DateTime.Now + "!'");
if (message != null)
Console.WriteLine(
"Recipient: {0}, Message: {1}, Date: {2}",
message.RecipientScreenName,
message.Text,
message.CreatedAt);
}