TwitterApiLibrary.Core 0.0.9

dotnet add package TwitterApiLibrary.Core --version 0.0.9                
NuGet\Install-Package TwitterApiLibrary.Core -Version 0.0.9                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="TwitterApiLibrary.Core" Version="0.0.9" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add TwitterApiLibrary.Core --version 0.0.9                
#r "nuget: TwitterApiLibrary.Core, 0.0.9"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install TwitterApiLibrary.Core as a Cake Addin
#addin nuget:?package=TwitterApiLibrary.Core&version=0.0.9

// Install TwitterApiLibrary.Core as a Cake Tool
#tool nuget:?package=TwitterApiLibrary.Core&version=0.0.9                

Twitter Api Library

Twitter API documentation

OAuth :

  • App-only (AppOnlyAuth)
  • SingleUserAuth
  • PKCE (PKCEAuth)
  • 3-legged (ThreeLeggedAuth)
  • Pin-based (PinBasedAuth)

Request :

  • RequestBuilder
  • OAuthRequestBuilder

Samples

App-Only

var auth = new AppOnlyAuth
{
    ConsumerKey = AppCredentials.ConsumerKey,
    ConsumerSecret = AppCredentials.ConsumerSecret
};

SingleUserAuth

var auth = new SingleUserAuth
{
    ConsumerKey = AppCredentials.ConsumerKey,
    ConsumerSecret = AppCredentials.ConsumerSecret,
    AccessToken = AppCredentials.AccessToken,
    AccessTokenSecret = AppCredentials.AccessTokenSecret
};

PKCE (PKCEAuth)

var auth = new PKCEAuth
{
    ClientID = AppCredentials.ClientID,
    ClientSecret = AppCredentials.ClientSecret,
    RedirectUri = AppCredentials.RedirectUri,
    Scopes = Scope.AllScopes,
    State = "state"
};

3-legged (ThreeLeggedAuth)

var auth = new ThreeLeggedAuth
{
    ConsumerKey = AppCredentials.ConsumerKey,
    ConsumerSecret = AppCredentials.ConsumerSecret,
    CallbackUrl = AppCredentials.RedirectUri
};

Pin-based (PinBasedAuth)

var auth = new PinBasedAuth
{
    ConsumerKey = AppCredentials.ConsumerKey,
    ConsumerSecret = AppCredentials.ConsumerSecret,
    CallbackUrl = AppCredentials.RedirectUri,
    GetPin = () =>
    {
        Console.Write("Enter the PIN number:");
        return Console.ReadLine() ?? string.Empty;
    }
};

Authorize

auth.Authorize();

Or async

await auth.AuthorizeAsync();

GenerateAuthorizationString Sample with RequestBuilder

var auth = new SingleUserAuth
{
    ConsumerKey = AppCredentials.ConsumerKey,
    ConsumerSecret = AppCredentials.ConsumerSecret,
    AccessToken = AppCredentials.AccessToken,
    AccessTokenSecret = AppCredentials.AccessTokenSecret
};

var request = new RequestBuilder("GET", "https://api.twitter.com/2/users/by/username/twitterdev");

var authorizationString = auth.GenerateAuthorizationString("GET", "https://api.twitter.com/2/users/by/username/twitterdev");
request.AddHeader("Authorization", authorizationString);

var responseString = request.Send();

OAuthRequestBuilder (Call automatically Authorize if required by default and GenerateAuthorizationString)

var request = new OAuthRequestBuilder(auth, "GET", "https://api.twitter.com/2/users/by/username/twitterdev");

request.AddQueryParameter("expansions", "pinned_tweet_id");
request.AddQueryParameter("tweet.fields", "attachments,author_id,context_annotations,conversation_id,created_at,edit_controls,entities,geo,id,in_reply_to_user_id,lang,non_public_metrics,public_metrics,organic_metrics,promoted_metrics,possibly_sensitive,referenced_tweets,reply_settings,source,text,withheld");
request.AddQueryParameter("user.fields", "created_at,description,entities,id,location,name,pinned_tweet_id,profile_image_url,protected,public_metrics,url,username,verified,verified_type,withheld");

var responseString = request.Send();

Or async

var responseString = await request.SendAsync();

UWP Application

var auth = new ThreeLeggedAuth
{
    ConsumerKey = ConsumerKey,
    ConsumerSecret = ConsumerSecret,
    CallbackUrl = RedirectUri,
};

await auth.GetRequestTokenAsync(auth.CallbackUrl);

var url = auth.PrepareAuthorizationUrl();
var authenticationResult =
    await WebAuthenticationBroker.AuthenticateAsync(WebAuthenticationOptions.None, new Uri(url), new Uri(auth.CallbackUrl));
if (authenticationResult.ResponseStatus == WebAuthenticationStatus.Success)
{
    var paramaters = auth.ParseParametersFromResponseUrl(authenticationResult.ResponseData);
    await auth.GetAccessTokenAsync(paramaters);
}
Product Compatible and additional computed target framework versions.
.NET net5.0 is compatible.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.0.9 317 2/14/2023