Modifying HomeController

Swing back to HomeController and add another action called GetHomeTimeline. This then takes the user credentials to find the home timeline tweets of the authenticated user. The user credentials consist of the following:

  • Consumer key
  • Consumer secret
  • Access token
  • Access secret

You will notice that these are all coming from the CoreTwitterConfiguration object. The twitter feed only consists of the limit set in the settings. I set mine to 10, so this should only contain 10 tweets. For every tweet in the feed, I extract the URL of the tweet and add it to a list of type TweetItem (the class we created earlier). If everything runs smoothly, I route to the HomeTimeline view.

Add the following code to your GetHomeTimeline ...

Get C# 7 and .NET Core 2.0 Blueprints now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.