andypiper / TwitterDotNetCore

A sample app using DotNetCore and the Twitter API v2
https://developer.twitter.com/en/docs/twitter-api/early-access
Apache License 2.0
4 stars 1 forks source link
csharp dotnet dotnet-core dotnetcore sample-app twitter twitter-api twitter-api-v2

TwitterDotNetCore

license v2 Twitter Follow

A simple sample app using DotNet Core and the new Twitter API.

By default, the code prompts for a Tweet ID and then fully hydrates that via the Twitter API v2. You may also enter a comma-separated list of IDs, as the API endpoint will also handle multiple IDs (up to 100).

To have the code request @jack's first Tweet (Tweet ID 20), and the same fields that are returned in API v1.1, comment out the REQUEST_URL value in Program.cs and uncomment the replacement in the next section.

What does it mean to 'hydrate a Tweet'?

Hydrating a Tweet means getting all available fields for a Tweet, given a Tweet ID (or a set of Tweet IDs)

Directions

Sign up for Twitter API Essential Access, and create a Project and an App. Generate access token and access token secret via the Twitter Developer Dashboard.

Install DotNet Core :-)

Copy .env.sample to .env and insert consumer keys and access tokens.

dotnet restore
dotnet run

Dependencies

The goal here is to provide a minimal example, so dependencies have been keep lightweight. The most useful library is OAuth.DotNetCore, which greatly simplifies the process of signing the API request. DotNetEnv is used to keep keys and tokens out of source control and in a sensible configuration file. NOTE: this is not production code, and you should take appropriate steps to protect your security keys and tokens.

  1. OAuth.DotNetCore
  2. DotNetEnv