I need to show tweet details (e.g tweet) when user click on <a href="https://twitter.com/screen_name/status/id"></a>
, so I'm trying to get this id using linq2twitter:
public static IEnumerable<TweetInfo> GetLatestTweets() {
var auth = new SingleUserAuthorizer {
CredentialStore = new SingleUserInMemoryCredentialStore {
ConsumerKey = Constants.TwitterAuth.ConsumerKey,
ConsumerSecret = Constants.TwitterAuth.ConsumerSecret,
AccessToken = Constants.TwitterAuth.AccessToken,
AccessTokenSecret = Constants.TwitterAuth.AccessTokenSecret
}
};
var twitterCtx = new TwitterContext( auth );
var tweets =
( from tweet in twitterCtx.Status
where tweet.Type == StatusType.User && tweet.ScreenName == Constants.TwitterAuth.ScreenName
select tweet ).Take( Constants.TwitterAuth.LatestTweetsCount ).ToList();
return tweets.Where( tweet => tweet != null && tweet.User != null )
.Select( tweet => new TweetInfo {
Text = tweet.Text,
TweetId = tweet.StatusID, // id for https://twitter.com/screen_name/status/id
ScreenName = tweet.ScreenName
}).ToList();
}
but I can't find the property in tweet which corresponds to this id. Do you have any suggestions as to how can I get this id?
That should be StatusID. Set a break point and run the code in RunUserTimelineQueryAsync:
Be sure to replace ScreenName with your screen name, and use the StatusID from the first tweet to pull up that URL in the browser. I see that the URL you're showing has "screen_name", which you should double check that you are replacing with the real screen name, e.g. "guidmiitestacc". You can download and run the Console demo code too.
So, if the StatusID property was "634349628574597120" and your user name is "guidmiitestacc", type the following value into the browser address bar:
https://twitter.com/guidmiitestacc/status/634349628574597120
You might want to set a break point in your code, after the query that populates tweets, to see that StatusID contains the ID. Then trace through the code to see if that gets changed or deleted anywhere.
Tip: There's also an ID property, but that's input only and LINQ to Twitter has alternate fields for output that either are like "StatusID" or have a "Response" suffix.