本文整理汇总了C#中LinqToTwitter.TwitterContext.CreateFriendshipAsync方法的典型用法代码示例。如果您正苦于以下问题:C# TwitterContext.CreateFriendshipAsync方法的具体用法?C# TwitterContext.CreateFriendshipAsync怎么用?C# TwitterContext.CreateFriendshipAsync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LinqToTwitter.TwitterContext
的用法示例。
在下文中一共展示了TwitterContext.CreateFriendshipAsync方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FollowOnTwitter
private static async void FollowOnTwitter(TwitterContext twitterContext, Profile profile)
{
if (!string.IsNullOrWhiteSpace(profile.Twitter))
{
try
{
string screenName = "";
if (!profile.Twitter.StartsWith("http"))
profile.Twitter = "http://" + profile.Twitter;
profile.Twitter = profile.Twitter.Replace("#!/", "");
Console.WriteLine("Attempting to follow {0} on Twitter", profile.Twitter);
var url = new Uri(profile.Twitter);
if (url.Segments != null && url.Segments.Length > 0)
screenName = url.Segments[url.Segments.Length - 1].Trim();
if (!string.IsNullOrEmpty(screenName))
{
Console.WriteLine("Found screen name {0} generated from {1}", screenName, profile.Twitter);
// ensure we aren't already following them
if (currentTwitterFriends.IndexOf(screenName) == -1)
{
var user = await twitterContext.CreateFriendshipAsync(screenName, false);
if (user != null && user.Status != null)
{
// if successful, increment count
Console.WriteLine("User Name: {0}, Status: {1}", user.Name, user.Status);
Console.WriteLine("Successfully followed {0} - {1} [{2}]", screenName, profile.FullName, profile.Id);
twitterCount++;
}
else
{
Console.WriteLine("NULL response");
}
}
else
{
Console.Write("Already following {0}. Skipping.", screenName);
}
}
}
catch (Exception exc)
{
Console.WriteLine("***** ERROR *****");
Console.WriteLine(exc.Message);
}
}
}
示例2: CreateFriendshipAsync
static async Task CreateFriendshipAsync(TwitterContext twitterCtx)
{
var user = await twitterCtx.CreateFriendshipAsync("JoeMayo", true);
if (user != null && user.Status != null)
Console.WriteLine(
"User Name: {0}, Status: {1}",
user.Name,
user.Status.Text);
}