![]() |
VOOZH | about |
dotnet add package TwitterOps --version 1.0.4
NuGet\Install-Package TwitterOps -Version 1.0.4
<PackageReference Include="TwitterOps" Version="1.0.4" />
<PackageVersion Include="TwitterOps" Version="1.0.4" />Directory.Packages.props
<PackageReference Include="TwitterOps" />Project file
paket add TwitterOps --version 1.0.4
#r "nuget: TwitterOps, 1.0.4"
#:package TwitterOps@1.0.4
#addin nuget:?package=TwitterOps&version=1.0.4Install as a Cake Addin
#tool nuget:?package=TwitterOps&version=1.0.4Install as a Cake Tool
A congruent way to use Twitter API.
Powered by .NET Core 3.1
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)
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:
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:
//Load module
var ops = new Operations(consumerKey, consumerSecret, tokenValue, tokenSecret);
//Execute a task
var tweet = ops.Tweets.PostTweet("This is a automated tweet!");
//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");
//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:
I'd recommend only using it with videos or gifs, with images PostTweetWithImageURL is more convinient.
//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.
//Load module
var ops = new Operations(consumerKey, consumerSecret, tokenValue, tokenSecret);
//Execute a task
var tweet = ops.Tweets.GetTweetById("1332104924184850432");
//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;
//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);
//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);
//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 net5.0 was computed. net5.0-windows net5.0-windows was computed. net6.0 net6.0 was computed. net6.0-android net6.0-android was computed. net6.0-ios net6.0-ios was computed. net6.0-maccatalyst net6.0-maccatalyst was computed. net6.0-macos net6.0-macos was computed. net6.0-tvos net6.0-tvos was computed. net6.0-windows net6.0-windows was computed. net7.0 net7.0 was computed. net7.0-android net7.0-android was computed. net7.0-ios net7.0-ios was computed. net7.0-maccatalyst net7.0-maccatalyst was computed. net7.0-macos net7.0-macos was computed. net7.0-tvos net7.0-tvos was computed. net7.0-windows net7.0-windows was computed. net8.0 net8.0 was computed. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 was computed. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 was computed. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
| .NET Core | netcoreapp3.1 netcoreapp3.1 is compatible. |
This package is not used by any NuGet packages.
This package is not used by any popular GitHub repositories.