本文整理汇总了C#中TweetSharp.TwitterService.GetTweet方法的典型用法代码示例。如果您正苦于以下问题:C# TwitterService.GetTweet方法的具体用法?C# TwitterService.GetTweet怎么用?C# TwitterService.GetTweet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TweetSharp.TwitterService
的用法示例。
在下文中一共展示了TwitterService.GetTweet方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main()
{
//Application.EnableVisualStyles();
//Application.SetCompatibleTextRenderingDefault(false);
//Application.Run(new Form1());
string tConsumerKey = "";
string tConsumerSecret = "";
string tAccessToken = "";
string tAccessSecret = "";
try
{
tConsumerKey = ConfigurationManager.AppSettings["TwitterConsumerKey"];
tConsumerSecret = ConfigurationManager.AppSettings["TwitterConsumerSecret"];
tAccessToken = ConfigurationManager.AppSettings["TwitterAccessToken"];
tAccessSecret = ConfigurationManager.AppSettings["TwitterAccessSecret"];
}
catch (Exception)
{
throw new System.ArgumentException("Error with Twitter keys", "twitter");
}
//build twitter connection
var twitService = new TweetSharp.TwitterService(tConsumerKey, tConsumerSecret, tAccessToken, tAccessSecret);
//build options to check for mentions
var mentionsOptions = new TweetSharp.ListTweetsMentioningMeOptions();
mentionsOptions.Count = 20;
mentionsOptions.SinceId = 300328033800306680;
//get the mentions
IEnumerable<TwitterStatus> mentions = twitService.ListTweetsMentioningMe(mentionsOptions);
List<TwitterStatus> listOfStuff = mentions.ToList();
listOfStuff.ForEach(
x =>
{
Console.WriteLine("Now gathering info about tweet #{0}.", x.Id);
Console.WriteLine("It is in response to tweet #{0}.", x.InReplyToStatusId);
var thatTweet = twitService.GetTweet(new GetTweetOptions { Id = (long)x.InReplyToStatusId });
Console.WriteLine("That tweet's text was {0}", thatTweet.Text);
Console.WriteLine("More importantly, heres the url it was referencing {0}", thatTweet.Entities.Urls[0].ExpandedValue);
string moveString = "not found";
if (x.Text.Contains("*"))
{
int startIndex = x.Text.IndexOf("*");
int endIndex = x.Text.LastIndexOf("*");
moveString = x.Text.Substring(startIndex, endIndex - startIndex + 1);
}
Console.WriteLine("The move attached to this tweet was {0}.", moveString);
}
);
Console.WriteLine("End of new API stuff");
}
示例2: DoMining
private static void DoMining()
{
using (var db = new TwitterDataContext(_connStr))
{
var devTwitters = (from d in db.DevTwitterAccounts
select d).ToList();
foreach (var devAccount in devTwitters)
{
ListTweetsOnListOptions listTweetOptions = new ListTweetsOnListOptions();
var service = new TwitterService(CONSUMER_KEY, CONSUMER_SECRET);
service.AuthenticateWith(ACCESS_TOKEN, ACCESS_SECRET);
var currentTweets = service.ListTweetsOnUserTimeline(
new ListTweetsOnUserTimelineOptions()
{
Count = 20,
ExcludeReplies = false,
IncludeRts = false,
ScreenName = "@" + devAccount.DevTwitterName,
SinceId = null,
MaxId = null
});
foreach (var tweet in currentTweets)
{
List<TwitterStatus> tweetsToInsert = new List<TwitterStatus>();
int? convIdToAddTo = null;
//We are basically going to keep on getting the reply-to tweets.
var currentTweet = tweet;
while (true)
{
if (currentTweet == null)
break;
List<Tweet> tweetExists;
tweetExists = (from t in db.Tweets
where t.TweetTwitterId == currentTweet.Id
select t).ToList();
if (tweetExists.Count > 0)
{
convIdToAddTo = tweetExists[0].TwitterConversationId;
break;
}
else
{
tweetsToInsert.Add(currentTweet);
}
if (currentTweet.InReplyToStatusId != null)
{
currentTweet = service.GetTweet(
new GetTweetOptions()
{
Id = currentTweet.InReplyToStatusId.Value
});
}
else
{
break;
}
}
if (tweetsToInsert.Count > 0)
{
tweetsToInsert = tweetsToInsert.OrderBy(x => x.CreatedDate).ToList();
if (convIdToAddTo == null)
{
string title = String.Empty;
if (tweetsToInsert[0].Text.Length > 60)
{
for (int i = 0; i < 60; i++)
{
title += tweetsToInsert[0].Text[i];
}
title += " (...)";
}
else
{
title = tweetsToInsert[0].Text;
}
TwitterConversation conversation = new TwitterConversation();
conversation.TwitterConvTitle = title;
conversation.LastBlueResponder = tweet.Author.ScreenName;
conversation.LastDevResponseDate = tweet.CreatedDate;
conversation.TwitterConvAuthor = tweetsToInsert[0].Author.ScreenName;
conversation.BlizzAreaId = (from t in tweetsToInsert
from d in db.DevTwitterAccounts
where d.DevTwitterName.ToLower() == t.Author.ScreenName.ToLower()
select d.BlizzAreaId).ToList()[0];
foreach (var twitterTweet in tweetsToInsert)
{
Tweet bpTweet = new Tweet();
//.........这里部分代码省略.........
示例3: FixTweets
private static void FixTweets()
{
var service = new TwitterService(CONSUMER_KEY, CONSUMER_SECRET);
service.AuthenticateWith(ACCESS_TOKEN, ACCESS_SECRET);
using (var db = new TwitterDataContext(_connStr))
{
var allTweets = (from t in db.Tweets
where t.TwitterInResponseToId == null
select t).ToList();
allTweets.Reverse();
Console.WriteLine(allTweets.Count);
foreach (var tweet in allTweets)
{
Console.WriteLine("{0}\n\n", tweet.TweetContent);
try
{
var desiredTweet = service.GetTweet(
new GetTweetOptions()
{
Id = tweet.TweetTwitterId
});
var desiredId = desiredTweet.InReplyToStatusId;
tweet.TwitterInResponseToId = desiredId;
db.SubmitChanges();
Console.WriteLine("Inserted. \n\n");
}
catch
{
}
}
}
}