TwitterOps 1.0.4
dotnet add package TwitterOps --version 1.0.4
NuGet\Install-Package TwitterOps -Version 1.0.4
<PackageReference Include="TwitterOps" Version="1.0.4" />
paket add TwitterOps --version 1.0.4
#r "nuget: TwitterOps, 1.0.4"
// Install TwitterOps as a Cake Addin
#addin nuget:?package=TwitterOps&version=1.0.4
// Install TwitterOps as a Cake Tool
#tool nuget:?package=TwitterOps&version=1.0.4
TwitterOps
A congruent way to use Twitter API.
Powered by .NET Core 3.1
Description
Right now capable of getting Tweets, Replies, Post Tweets... can be used for whatever automation needed.
(dropped project because Twitter permabanned me for no reason, haha)
Usage
Load Main Class
using System;
using TwitterOps;
using System.Configuration;
using System.Linq;
using System.Collections.Generic;
namespace testConsole
{
class Program
{
static void Main(string[] args)
{
//Example
//Load key data
string consumerKey = ConfigurationManager.AppSettings["consumerKey"];
string consumerSecret = ConfigurationManager.AppSettings["consumerSecret"];
string tokenValue = ConfigurationManager.AppSettings["tokenValue"];
string tokenSecret = ConfigurationManager.AppSettings["tokenSecret"];
//Load module
var ops = new Operations(consumerKey, consumerSecret, tokenValue, tokenSecret);
}
}
}
As you can see, you must declare the class Operations with your tokens. consumerKey and consumerSecret are your app tokens. tokenValue and tokenSecret are the tokens of a linked twitter account.
This class can reach to other classes which represents modules for the different forms of operations. At this moment it only contains:
- Tweets
- Users
- Media
Depending of the module, each operation will return a class model. These classes has every metadata needed for any complex scripting.
The declared ops variable can be used for any of the following operations. I will categorize it by module for consistency:
Tweets
Post a Tweet
//Load module
var ops = new Operations(consumerKey, consumerSecret, tokenValue, tokenSecret);
//Execute a task
var tweet = ops.Tweets.PostTweet("This is a automated tweet!");
Post a Tweet with image
//Load module
var ops = new Operations(consumerKey, consumerSecret, tokenValue, tokenSecret);
//Post tweet with URL of image
var tweet = ops.Tweets.PostTweetWithImageURL("kimika is cute!", "https://pbs.twimg.com/media/EnyWXkFWEAETjMA?format=jpg&name=small");
//Also can be a List<string>. 4 max
var tweet2 = ops.Tweets.PostTweetWithImagesURL("aoi is cute!", new List<string> { "https://pbs.twimg.com/media/DpUq61zUUAEv16G?format=jpg&name=small", "https://pbs.twimg.com/media/D7LPDN1VUAE0cx2?format=jpg&name=small", "https://pbs.twimg.com/media/Drtz9kiU4AA_MbM?format=jpg&name=small", "https://pbs.twimg.com/media/DpuEzHXU8AAy4AQ?format=jpg&name=small" });
//Of course can be loaded locally
var tweet3 = ops.Tweets.PostTweetWithImagePath(@"D:\STUFF\Waiff\2d waifus\2020\aikatsu!\hikami sumire\geshumaro\(danbooru.donmai.us-posts-4089209)-30166199557befbd8c6a931830222060.jpg");
Post a Tweet with media
//Load module
var ops = new Operations(consumerKey, consumerSecret, tokenValue, tokenSecret);
//Load media
var media = ops.Media.UploadCustomMediaFromPath(@"C:\Users\salivosa\Downloads\testo1.mp4", TwitterOps.Operation.Media.MediaData.MediaCategory.tweet_video);
//Post Tweet with uploaded media
var tweet = ops.Tweets.PostTweetWithMedia("lol", media);
The enum Media.MediaData.MediaCategory can select any of these values:
- tweet_image
- tweet_gif
- tweet_video
- amplify_video
I'd recommend only using it with videos or gifs, with images PostTweetWithImageURL is more convinient.
Post a Thread
//Load module
var ops = new Operations(consumerKey, consumerSecret, tokenValue, tokenSecret);
//Execute a task
var thread = ops.Tweets.PostThread(@"Once upon a time there was a lovely princess. But she had an enchantment upon her of a fearful sort which could only be broken by love's first kiss. She was locked away in a castle guarded by a terrible fire-breathing dragon. Many brave knights had attempted to free her from this dreadful prison, but non prevailed. She waited in the dragon's keep in the highest room of the tallest tower for her true love and true love's first kiss. (laughs) Like that's ever gonna happen. What a load of - (toilet flush)", false);
Second argument is a boolean which determines if the string can be splitted by dot. If is false then it will split every 280 characters.
Get a Tweet
//Load module
var ops = new Operations(consumerKey, consumerSecret, tokenValue, tokenSecret);
//Execute a task
var tweet = ops.Tweets.GetTweetById("1332104924184850432");
Get Replies of a Tweet
//Load module
var ops = new Operations(consumerKey, consumerSecret, tokenValue, tokenSecret);
//Get Tweet
var tweet = ops.Tweets.GetTweetById("1332104924184850432");
//Get Replies of obtained Tweet
var replies = tweet.replies;
Reply a Tweet
//Load module
var ops = new Operations(consumerKey, consumerSecret, tokenValue, tokenSecret);
//Get Tweet
var tweet = ops.Tweets.GetTweetById("1332104924184850432");
//Reply to obtained Tweet
var reply = ops.Tweets.PostReplyTweet("agreed!", tweet);
Quote a Tweet
//Load module
var ops = new Operations(consumerKey, consumerSecret, tokenValue, tokenSecret);
//Get Tweet
var tweet = ops.Tweets.GetTweetById("1332104924184850432");
//Reply to obtained Tweet
var quoted_tweet = ops.Tweets.PostTweetQuote("humillado!", tweet);
Users
Get User information
//Load module
var ops = new Operations(consumerKey, consumerSecret, tokenValue, tokenSecret);
//Get User by Username
var user = ops.Users.GetUserByScreenName("realDonaldTrump");
//Get User by ID
user = ops.Users.GetUserById("25073877");
//Get User Follows
var follows = user.follows;
//Get User Followers
var followers = user.followers;
user variable has information such as creation datetime, follows, followers, profile image url and more.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. 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-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 | netcoreapp3.1 is compatible. |
-
.NETCoreApp 3.1
- HtmlAgilityPack (>= 1.11.24)
- Newtonsoft.Json (>= 12.0.3)
- OAuth.DotNetCore (>= 3.0.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.