Get previous tweets

Mar 9, 2014 at 8:01 AM
Hello linvi,

is it possible if I can get all the previous tweets who mention my screen name?
if possible, can you give me an example?
Coordinator
Mar 9, 2014 at 1:20 PM
Hi,

You just need to do a search with '@' in front of your screename :
var results = Search.SearchTweets("@SCREEN_NAME");
If you want to have more control over your request you can create a search parameter:
var searchQuery = Search.GenerateSearchTweetParameter("@SCREEN_NAME");
searchQuery.MaximumNumberOfResults = 200;
var results = Search.SearchTweets(searchQuery);
Regards,
Linvi
Mar 14, 2014 at 7:53 PM
hI linvi, i'm trying to get the lastest 4 tweets for a specific tweet posted in a specific screen, in my case mteodoro85.

what query should i use.
var searchQuery = Search.GenerateSearchTweetParameter("@mteodoro85");
searchQuery.MaximumNumberOfResults = 4;
var results = Search.SearchTweets(searchQuery);
this code returns the error
Value cannot be null.
Parameter name: s

Regars,
Marco
Coordinator
Mar 14, 2014 at 8:31 PM
Hi,

Do you have the latest version 0.9.0.3?

Linvi
Mar 14, 2014 at 8:35 PM
no 9.0.0.0, i will update it. and i will let you know. thanks for the fast reply
Mar 14, 2014 at 8:39 PM
No same issue... this query should work? it's correctly what i've posted above?
Mar 14, 2014 at 9:59 PM
Edited Mar 14, 2014 at 10:36 PM
HI marcoteodoro,

While I'm nowhere near as useful as Linvi,

I did try your code and it also returned nothing for me too.

But then I slightly changed by using my twitter account instead and it indeed returns the last 4 tweets with @kamehamehamehaa (my account) in them
 var searchQuery = Search.GenerateSearchTweetParameter("@kamehamehamehaa");
            searchQuery.MaximumNumberOfResults = 4;
            var results = Search.SearchTweets(searchQuery);
I believe the query is searching for tweets with "@mteodoro85" or "@kamehamehamehaa" in them rather than searching by user @mteodoro85 (or @kamehamehamehaa)

If this does not make sense, log into that twitter account and post a tweet saying "@mteodoro85" and then try your code again it should return one value.



What I'm trying to say is it is returning null because there are no tweets containing the phrase '@mteodoro85'

You could try the method .GetMentionsTimeline() which should retrieve any tweet directed at your account and not just containing the words '@mteodoro85'.
Marked as answer by linvi on 3/15/2014 at 1:22 PM
Coordinator
Mar 15, 2014 at 12:37 AM
Hi both of you :)

I think Phoenix is right, I did not take time to consider that you might have not posted tweets with the @. Twitter does not provide search saying get me all the tweets posted to...

Instead, when you send a tweet in reply to another one, it automatically adds an @USER_NAME in the tweet. Which then make it 'searchable'.

Thank you phoenix :)
Linvi
Mar 15, 2014 at 10:31 AM
Edited Mar 15, 2014 at 12:06 PM
ok i got it, the problem was not on the code but on my tweeter account. i did as pheonix told and it works now.

thanks a lot for you help.

other think that i was missing was the execute operation with credentials. i was not throwing any exception it just returns a empty result. maybe someone new on this would have the same issue so i let it here these mention
 var credentials = TwitterCredentials.CreateCredentials(twitterToken, twitterTokenSecrett, twitterConsumer_Key, twitterConsumer_Secret);
  TwitterCredentials.ExecuteOperationWithCredentials(credentials, () =>
            {
                var c = Tweetinvi.Timeline.GetMentionsTimeline(4);
            });
Mar 15, 2014 at 2:28 PM
No problem, will help out where I feel I can :)