RickAndMSFT
RickAndMSFT

Reputation: 22810

linqToTwitter UserID always zero

I need to construct the URL to the original tweet as

 http://twitter.com/{twitter-user-id}/status/{tweet-staus-id}

Joe's code on linq2twitter works fine, but when I replace User.ScreenNameResponse from his sample with User.UserID, the UserID is always zero. The debugger shows tweet.UserID is also zero. Most fields are populated.

My code:

var twitterCtx = new TwitterContext(getAuth());

var searchResponse =
          await
          (from search in twitterCtx.Search
           where search.Type == SearchType.Search &&
                 search.Query == searchTxt &&
                 search.Count == searchCount
           select search)
          .SingleOrDefaultAsync();

if (searchResponse != null && searchResponse.Statuses != null)
   searchResponse.Statuses.ForEach(tweet =>
       Console.WriteLine(
           "User: {0}, Tweet: {1}",
           //tweet.User.ScreenNameResponse,
           tweet.User.UserID,
           tweet.Text));
  

Version: 3.1.1 from NuGet using app authentication.

How can I get the UserID so I can construct the tweet URL?

This SO thread (use id_str) did not help.

Upvotes: 1

Views: 358

Answers (1)

Joe Mayo
Joe Mayo

Reputation: 7513

That would be in tweet.User.UserIDResponse.

A bit of background: Anything used as an input parameter is also looked at in the query response, so if a user omits the parameter in a query but the twitter response contains a value, it was being filtered out of the results. To fix this, I adopted a convention where any return parameters also match input parameters would have a 'Response' suffix. e.g. ScreenName (input) and ScreenNameResponse (output). To find which values are input, the docs for each API (including Search) call contain the input/filter parameters.

Upvotes: 2

Related Questions