From the LINQ to Twitter FAQ:
4. Why are ScreenName
and/or UserID
properties null in the User
entity response from Twitter?
The ScreenName
and UserID
properties are input only, allowing you to see the parameters you provided in your query.
- For v2.1.x, use the
Identifier
property, which has the ScreenName
and UserID
returned from Twitter.
- For v3.0.x and later, use the
ScreenNameResponse
and UserIDResponse
properties.
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 call contain the input/filter parameters.
Here's an example, from LINQ to Twitter Samples code:
static void PrintTweetsResults(List<Status> tweets)
{
if (tweets != null)
tweets.ForEach(tweet =>
{
if (tweet != null && tweet.User != null)
Console.WriteLine(
"ID: [{0}] Name: {1}\n\tTweet: {2}",
tweet.StatusID, tweet.User.ScreenNameResponse, tweet.Text);
});
}