本文整理汇总了C#中TweetSharp.TwitterService.ListTweetsOnHomeTimeline方法的典型用法代码示例。如果您正苦于以下问题:C# TwitterService.ListTweetsOnHomeTimeline方法的具体用法?C# TwitterService.ListTweetsOnHomeTimeline怎么用?C# TwitterService.ListTweetsOnHomeTimeline使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TweetSharp.TwitterService
的用法示例。
在下文中一共展示了TwitterService.ListTweetsOnHomeTimeline方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Index
public ActionResult Index()
{
if (Request.IsAuthenticated)
{
var claimsIdentity = HttpContext.User.Identity as ClaimsIdentity;
var claims = claimsIdentity.Claims;
var accessTokenClaim = claims.FirstOrDefault(x => x.Type == Startup.TwitterAccessTokenClaimType);
var accessTokenSecretClaim =
claims.FirstOrDefault(x => x.Type == Startup.TwitterAccessTokenSecretClaimType);
if (accessTokenClaim != null && accessTokenSecretClaim != null)
{
var service = new TwitterService(
Startup.TwitterConsumerKey,
Startup.TwitterConsumerSecret,
accessTokenClaim.Value,
accessTokenSecretClaim.Value
);
ViewBag.Tweets = service.ListTweetsOnHomeTimeline(new ListTweetsOnHomeTimelineOptions());
}
}
return View();
}
示例2: Connect
private void Connect(string consumerKey, string consumerSecret, string accessToken, string accessTokenSecret)
{
// In v1.1, all API calls require authentication
var service = new TwitterService(consumerKey, consumerSecret);
service.AuthenticateWith(accessToken, accessTokenSecret);
Log("Connected");
TwitterRateLimitStatusSummary rate = service.GetRateLimitStatus(new GetRateLimitStatusOptions());
Log("Limimte rate: " + rate.RawSource);
var tweets = service.ListTweetsOnHomeTimeline(new ListTweetsOnHomeTimelineOptions());
foreach (var tweet in tweets)
{
Console.WriteLine("{0} says '{1}'", tweet.User.ScreenName, tweet.Text);
}
TwitterCursorList<TwitterUser> friends = service.ListFollowers(new ListFollowersOptions());
Log("Friends: " + friends.Count);
foreach (var friend in friends)
{
Log(String.Format("Friend: {0}", friend.Name));
}
}
示例3: 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;
}
}
示例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;
}
}
示例5: GetAllTweets
/// <summary>
/// Gets all the users tweets.
/// </summary>
/// <returns></returns>
public IList<Tweet> GetAllTweets()
{
List<Tweet> tweets = new List<Tweet>();
TwitterService twitterService = new TwitterService(AuthenticationTokens.TwitterConsumerKey, AuthenticationTokens.TwitterConsumerSecret);
twitterService.AuthenticateWith(AuthenticationTokens.TwitterConsumerKey, AuthenticationTokens.TwitterConsumerSecret,
_authentication.AccessToken, _authentication.AccessTokenSecret);
TwitterUser twitterUser = twitterService.VerifyCredentials();
//ListTweetsOnHomeTimeline only returns 200 (or 800?) results each go. Need to send the requests a few times per hour
//with the paging/counts set?
IEnumerable<TwitterStatus> returnedTweets = null;
//try it a few times
int retryCount = 0;
while (returnedTweets == null)
{
returnedTweets = twitterService.ListTweetsOnHomeTimeline(200);
retryCount++;
//give up after 5 retries
if (retryCount == 5)
return tweets;
}
foreach (var returnedTweet in returnedTweets)
{
Tweet tweet = new Tweet();
TwitterStatus statusToExamine = returnedTweet;
if (returnedTweet.RetweetedStatus != null)
{
statusToExamine = returnedTweet.RetweetedStatus;
}
tweet.Author = new Linker() { Id = statusToExamine.Author.ScreenName, Name = statusToExamine.Author.ScreenName };
tweet.Content = statusToExamine.Text;
tweet.DatePosted = statusToExamine.CreatedDate;
tweet.TweetId = statusToExamine.Id;
tweet.ReTweetCount = GetRetweetCountFromRawData(statusToExamine.RawSource);
tweets.Add(tweet);
}
return tweets;
}
示例6: GetSelectedTweets
public IEnumerable<TwitterStatus> GetSelectedTweets()
{
IEnumerable<TwitterStatus> tweets = null;
try
{
var service = new TwitterService(_consumerKey, _consumerSecret);
service.AuthenticateWith(_accessToken, _accessTokenSecret);
tweets = service.ListTweetsOnHomeTimeline(new ListTweetsOnHomeTimelineOptions()).Take(5);
foreach (var tweet in tweets)
{
Console.WriteLine("{0} says '{1}'", tweet.User.ScreenName, tweet.Text);
}
}
catch (Exception ex)
{
}
return tweets;
}
示例7: Get
// GET api/values
public IEnumerable<Tweet> Get()
{
var tweets = new List<Tweet>();
var service = new TwitterService(TWITTER_CONSUMER_KEY, TWITTER_CONSUMER_SECRET);
service.AuthenticateWith(OAUTH_TOKEN, OAUTH_TOKEN_SECRET);
foreach (var serviceTweet in service.ListTweetsOnHomeTimeline(5))
{
var tweet = new Tweet()
{
CreatedDate = serviceTweet.CreatedDate,
Id = serviceTweet.Id.ToString(),
Text = serviceTweet.Text,
UserName = serviceTweet.Author.ScreenName
};
tweets.Add(tweet);
}
return tweets;
}
示例8: ListInc
public ActionResult ListInc()
{
// In v1.1, all API calls require authentication
var service = new TwitterService(_consumerKey, _consumerSecret);
service.AuthenticateWith(_accessToken, _accessTokenSecret);
IEnumerable<TwitterStatus> tweets = service.ListTweetsOnHomeTimeline(new ListTweetsOnHomeTimelineOptions());
foreach (TwitterStatus tweet in tweets)
{
ViewBag.Tweet = tweet.Text;
}
return View();
}
示例9: GetTweets
private void GetTweets()
{
TweetList.DataContext = _tweets;
_tweets.Clear();
int twitterCount = 0;
var service = new TwitterService("gdszkrjT9BXALsntZI3BxQ", "ltpb4xzjzxRf1w9Sq6wqhwOBfDNCKpWDcUkQyth5MeE");
service.AuthenticateWith("1966078789-R92gYWO9THXuYJ5uE6DkifcQ9mDLEZFT6dgUcuH",
"g3Jb0b8BSt4CgSDrWJMatw6DaXwtocPk4kMhX52jnq4");
IEnumerable<TwitterStatus> tweets = service.ListTweetsOnHomeTimeline(new ListTweetsOnHomeTimelineOptions());
try
{
foreach (TwitterStatus tweet in tweets)
{
if (twitterCount < 6)
{
String name = tweet.User.ScreenName;
String status = tweet.Text;
String timeString;
DateTime time = tweet.CreatedDate.ToLocalTime();
TimeSpan timePassed = DateTime.Now.Subtract(time);
if (timePassed.TotalSeconds < 60)
{
var timeInt = (int) (Math.Floor(timePassed.TotalSeconds));
timeString = timeInt.ToString("N0") + " seconds ago";
}
else if (timePassed.TotalMinutes < 60)
{
var timeInt = (int) (Math.Floor(timePassed.TotalMinutes));
timeString = timeInt.ToString("N0") + " minutes ago";
}
else if (timePassed.TotalHours < 24)
{
var timeInt = (int) Math.Floor(timePassed.TotalHours);
timeString = timeInt.ToString("N1") + " hours ago";
}
else
{
var timeInt = (int) (Math.Floor(timePassed.TotalDays));
timeString = timeInt.ToString("N1") + " days ago";
}
_tweets.Add(new Tweet("@" + name, status, timeString.Replace(".0", "")));
twitterCount++;
}
}
}
catch (NullReferenceException)
{
}
}
示例10: AccessTokenQuery_QueryResponse
void AccessTokenQuery_QueryResponse(object sender, WebQueryResponseEventArgs e)
{
try
{
StreamReader reader = new StreamReader(e.Response);
string strResponse = reader.ReadToEnd();
var parameters = MainUtil.GetQueryParameters(strResponse);
ObjCommon.Twittertoken = parameters["oauth_token"];
ObjCommon.TwitterAccessTokenSecret = parameters["oauth_token_secret"];
ObjCommon.TwitterScreenName = parameters["screen_name"];
ObjCommon.SaveSettings();
userLoggedIn();
if (userID != "" && userScreenName != "")
{
var service = new TwitterService(consumerKey, consumerKeySecret);
service.AuthenticateWith(accessToken.ToString(), accessTokenSecret);
service.ListTweetsOnHomeTimeline(new TweetSharp.ListTweetsOnHomeTimelineOptions() { Count = 20 }, (ts, rep) =>
{
if (rep.StatusCode == HttpStatusCode.OK)
{
}
});
}
}
catch (Exception ex)
{
Dispatcher.BeginInvoke(() =>
{
MessageBox.Show(ex.Message);
});
}
}
示例11: twitterToolStripMenuItem_Click_1
private void twitterToolStripMenuItem_Click_1(object sender, EventArgs e)
{
TwitterClientInfo twitterClientInfo = new TwitterClientInfo();
twitterClientInfo.ConsumerKey = consumerKey; //Read ConsumerKey out of the app.config
twitterClientInfo.ConsumerSecret = consumerSecret; //Read the ConsumerSecret out the app.config
TwitterService twitterService = new TwitterService(consumerKey, consumerSecret);
requestToken = twitterService.GetRequestToken();
if (AdvancedSoftwareProject.Properties.Settings.Default.AccessToken != "" && AdvancedSoftwareProject.Properties.Settings.Default.AccessTokenSecret != "")
{
try
{
twitterService.AuthenticateWith(AdvancedSoftwareProject.Properties.Settings.Default.AccessToken, AdvancedSoftwareProject.Properties.Settings.Default.AccessTokenSecret);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
authTwitter(twitterService);
}
}
else
{
authTwitter(twitterService);
}
var options = new ListTweetsOnHomeTimelineOptions();
var currentTweets = twitterService.ListTweetsOnHomeTimeline(options);
List<TwitterStatus> tweets = currentTweets.ToList();
//tweets[i].User.ScreenName
//See https://github.com/danielcrenna/tweetsharp for more info on how to use tweets etc
twitterFeed.DocumentText = "";
string twitterHTML = "<div style = \"color:0099FF\">";
for (int i = 0; i < tweets.Count; i++)
{
if (i != tweets.Count - 1)
{
twitterHTML = twitterHTML + tweets[i].TextAsHtml + "<br><br>";
}
else
{
twitterHTML = twitterHTML + tweets[i].TextAsHtml + "</div>";
}
}
twitterFeed.DocumentText = twitterHTML;
}
示例12: GetTwitterData
public List<SportsBuzzTweet> GetTwitterData(string username, string filter)
{
List<TwitterStatus> tweets = new List<TwitterStatus>();
TwitterService service;
if (filter == "NBA" || filter == "All")
{
service = new TwitterService("evXjkuCvpwXKBWlnzPaDlw", "6WAwfe87ZAMYSpmh2JvtxfoOwS7lZdMyOQ0aZytsYU");
service.AuthenticateWith("1146287640-bXJoH4wh5vTkFdQLIbl2xcmx4iyl4lWOybzqNfp", "yqd2izA8mvYULBM3y9Z7TQdxWabPhcRmn53GKk9eQ");
tweets.AddRange(service.ListTweetsOnHomeTimeline(new ListTweetsOnHomeTimelineOptions() { Count = 200 }).ToList());
//tweets = service.ListTweetsOnHomeTimeline(new ListTweetsOnHomeTimelineOptions() { Count = 200 }).ToList();
}
if (filter == "NFL" || filter == "All")
{
service = new TwitterService("Pcg1nt7s1TGHHCmfph80oQ", "Gda56oYVh7a4lKCCBLbWW6EhwYgj5sSQFwBivBYag");
service.AuthenticateWith("1450834111-WDeHWOxcCujGYbkibfVWj8doZ9XeAczbMyLgpPA", "lClYwynFhpOWWUm3iAUFuqzIOHakQczlavFZdODJ8g");
tweets.AddRange(service.ListTweetsOnHomeTimeline(new ListTweetsOnHomeTimelineOptions() { Count = 200 }).ToList());
//tweets = service.ListTweetsOnHomeTimeline(new ListTweetsOnHomeTimelineOptions() { Count = 200 }).ToList();
}
// var service = new TwitterService(_consumerKey, _consumerSecret);
//service.AuthenticateWith(_accessToken, _accessTokenSecret);
tweets = tweets.OrderBy(c => c.CreatedDate).ToList();
List<SportsBuzzTweet> sbTweets = new List<SportsBuzzTweet>();
SportsBuzzTweet sbTweet;
foreach (var tweet in tweets)
{
sbTweet = new SportsBuzzTweet();
sbTweet.ProfileImageUrl = tweet.User.ProfileImageUrl;
sbTweet.ScreenName = tweet.User.ScreenName;
//if (filter == "NBA")
// sbTweet.TweetText = "***NBA***" + tweet.Text;
//else
sbTweet.TweetText = tweet.Text;
sbTweets.Add(sbTweet);
Console.WriteLine("{0} says '{1}'", tweet.User.ScreenName, tweet.Text);
}
return sbTweets;
//return tweets.ToList();
//string url = "http://twitter.com/statuses/friends_timeline.xml";
////string user = Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(username + ":" + password));
//HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(url);
//request.Method = "POST"; // <--- you probably need to change this to a GET after a twitter change a couple of months ago.
//string password = "ficoand21";
//request.Credentials = new NetworkCredential(username, password);
//WebResponse response = request.GetResponse();
//StreamReader reader = new StreamReader(response.GetResponseStream());
//string responseString = reader.ReadToEnd();
//reader.Close();
//XmlDocument xmld = new XmlDocument();
//xmld.LoadXml(responseString);
//XDocument document = XDocument.Parse(responseString);
//var query = from e in document.Root.Descendants()
// where e.Element("user") != null
// select new UserStatusSvc
// {
// UserName = e.Element("user").Element("screen_name").Value,
// ProfileImage = e.Element("user").Element("profile_image_url").Value,
// Status = HttpUtility.HtmlDecode(e.Element("text").Value),
// StatusDate = e.Value.ParseDateTime().ToString()
// };
//var users = (from u in query
// where u.Status != ""
// select u).ToList();
//return (users.ToArray());
}
示例13: GetTwitterTweets
public static List<ModelTwitterFeedsDetails> GetTwitterTweets(string ScreenName)
{
ModelTwitterFeeds modelTwitterFeeds = new ModelTwitterFeeds();
List<ModelTwitterFeedsDetails> lstModelTwitterFeedsDetail = new List<ModelTwitterFeedsDetails>();
try
{
/*>>> API Creadentials <<<<////
>> Under Informnation is creating from Personal Account Information API
>> For any change in this credentials Login Account : [email protected]
>> API Name : News Get Application
>> Please don't change any word without permission from following API Admin*/
string _consumerKey = "cvRCCaqLUlM9SyolFwYEQQ2uZ";
string _consumerSecret = "sVvOgCPwuzXo37v4qjAriGbftwEefMC9xNadPQLTsoOkeqiJ8C";
string _accessToken = "65042389-YQ3jLfP1RWu9Q7So9VAj3Rc3J9oMB0Suuv0jlioAN";
string _accessTokenSecret = "yHMVHihkHAaCIOJi2M9WEOq4fpODY1a0hdS92J9OZEJEL";
// API access Data End
var service = new TwitterService(_consumerKey, _consumerSecret);
//var tweets = new ListTweetsOnHomeTimelineOptions();
service.AuthenticateWith(_accessToken, _accessTokenSecret);
IAsyncResult result = service.BeginListTweetsOnHomeTimeline(new ListTweetsOnHomeTimelineOptions());
IEnumerable<TwitterStatus> tweets = service.EndListTweetsOnHomeTimeline(result);
foreach (var tweet in tweets)
{
if (tweets != null)
{
modelTwitterFeeds.FeedId = 0;
modelTwitterFeeds.UserPageId = 0;
modelTwitterFeeds.UserPageTitle = String.Empty;
modelTwitterFeeds.UserScreenName = String.Empty;
modelTwitterFeeds.UserPageLanguage = String.Empty;
modelTwitterFeeds.UserPageFollowers = 0;
modelTwitterFeeds.UserPageCoverImageURL = String.Empty;
modelTwitterFeeds.UserPageLogoImage = String.Empty;
}
var st1 = tweet.Text; //string
var st2 = tweet.Source; //string
var st3 = tweet.TextAsHtml; //string
var st4 = tweet.TextDecoded; //string
var st5 = tweet.RetweetedStatus; //TwitterStatus
var st6 = tweet.RetweetCount; //int
var st7 = tweet.RawSource; //string
var st8 = tweet.Place; //TwitterPlace
var st9 = tweet.Location; //TwitterGeoLocation
var st10 = tweet.Language; //string
var st11 = tweet.IsTruncated; //bool
var st12 = tweet.IsRetweeted; //bool
var st13 = tweet.IsPossiblySensitive; //bool is nullable
var st14 = tweet.IsFavorited; //bool
var st15 = tweet.InReplyToUserId; //long is nullable
var st16 = tweet.InReplyToStatusId; //long is nullable
var st17 = tweet.InReplyToScreenName; //string
var st18 = tweet.IdStr; //string
var st19 = tweet.Id; //long
var st20 = tweet.FavoriteCount; //int
var st21 = tweet.ExtendedEntities; //TwitterExtendedEntities
var st22 = tweet.Entities; //TwitterEntities
var st23 = tweet.CreatedDate; //DateTime
var st24 = tweet.Author; //ITweeter
}
//TwitterAccount user = new TwitterAccount.
//TwitterUser twitterUser =
//>>GET OTHER USER TIMELINE//BeginListTweetsOnHomeTimeline
TwitterService t_service = new TwitterService(_consumerKey, _consumerSecret);
t_service.AuthenticateWith(_accessToken, _accessTokenSecret);
var t_options = new ListTweetsOnHomeTimelineOptions();
t_options.ExcludeReplies = true;
var t_tweets = t_service.ListTweetsOnHomeTimeline(t_options);
//ListTweetsOnSpecifiedUserTimeline
string ScreenNameBBCArabic = "BBCArabic";
string ScreenNameCNNArabic = "cnnarabic";
string ScreenName1 = "garbo_speaks";
var User_OptionInit = new ListTweetsOnUserTimelineOptions { ScreenName = ScreenNameCNNArabic, Count = 200, ExcludeReplies = true };
var User_Tweets = service.ListTweetsOnUserTimeline(User_OptionInit);
string TweetText = String.Empty;
foreach (var tweet in User_Tweets)
{
var userDetail = tweet.User;
if (false)
{
var us1 = tweet.User.ContributorsEnabled; //bool?
var us2 = tweet.User.CreatedDate;
var us3 = tweet.User.Description;
var us4 = tweet.User.FavouritesCount;
var us5 = tweet.User.FollowersCount;
var us6 = tweet.User.FollowRequestSent;
var us7 = tweet.User.FriendsCount;
var us8 = tweet.User.Id;
var us9 = tweet.User.IsDefaultProfile;
var us10 = tweet.User.IsGeoEnabled;
var us11 = tweet.User.IsProfileBackgroundTiled;
var us12 = tweet.User.IsProtected;
var us13 = tweet.User.IsTranslator;
//.........这里部分代码省略.........