how do I include twitter timestamp ?

Nov 6, 2012 at 8:01 AM
Edited Nov 6, 2012 at 8:03 AM
var statusTweets = 
from tweet in twitterCtx.Status
where tweet.Type == StatusType.User &&
select tweet;

Hi, I am quite new to twitter api. Above is my code for retrieving "mayo" tweets. However, the information retrieved does not include timestamp. How can I include timestamp? .CreatedAt? Guide me please. Thank you

Coordinator
Nov 6, 2012 at 10:44 PM

Hi,

Yes, the CreatedAt property contains Twitter's timestamp. BTW, either tweet.UserID or tweet.ScreenName are required for this query.

Joe

Nov 7, 2012 at 2:07 AM
Edited Nov 7, 2012 at 2:13 AM

Hi, 

Thank you for reply. 

var statusTweets =
	from tweet in twitterCtx.Status
	where tweet.Type == StatusType.User &&
	tweet.ScreenName == "Twitter" &&

//I came across one article using this but I could not use it.
	tweet.Timestamp = tweet.CreatedAt.ToLocalTime() &&  

	tweet.CreatedAt .....//How should I go about?� 

 select tweet;
Nov 7, 2012 at 2:11 AM
Edited Nov 7, 2012 at 2:12 AM
Hi, 

Thank you for reply. 

 
var statusTweets =
	from tweet in twitterCtx.Status
	where tweet.Type == StatusType.User &&
	tweet.ScreenName == "Twitter" &&

//I came across one article using this but I could not use it.
	tweet.Timestamp = tweet.CreatedAt.ToLocalTime() &&  

	tweet.CreatedAt .....//How should I go about?� 

 select tweet;
Coordinator
Nov 7, 2012 at 11:58 AM
Edited Nov 7, 2012 at 12:00 PM

The CreatedAt property is output only. So, you can't use it as a filter. Here's the documentation on StatusType.User:

http://linqtotwitter.codeplex.com/wikipage?title=Querying%20the%20User%20Timeline&referringTitle=Making%20Status%20Queries%20and%20Calls

The Parameters/Filters list shows what you can use in the where clause of the query. In the documentation, there's also an Entity field with a link to the returned type. In this case the return type will be Status, which is documented here:

http://linqtotwitter.codeplex.com/wikipage?title=Status%20Entity&referringTitle=Querying%20the%20User%20Timeline

There are many examples in the downloadable source code that will give you an idea of how to use LINQ to Twitter. Here's an example that uses CreatedAt:

 

            var lastN = 11;
            var screenName = "JoeMayo";

            var statusTweets =
                from tweet in twitterCtx.Status
                where tweet.Type == StatusType.User
                      && tweet.ScreenName == screenName
                      && tweet.Count == lastN
                select tweet;

            foreach (var tweet in statusTweets)
            {
                Console.WriteLine(
                    "(" + tweet.StatusID + ")" +
                    "[" + tweet.User.ID + "]" +
                    tweet.User.Name + ", " +
                    tweet.Text + ", " +
                    tweet.CreatedAt);
            }

@JoeMayo

Nov 8, 2012 at 12:40 AM

Hi , I am done with this issue :D thank you for guiding!