Jump to content

Twitter Posting!


Malcolm

Recommended Posts

I used to troll a bit with my twitter by tweeting out updates when my bots would gain certain levels or I would mule a certain amount.

I felt like it was kind of a funny troll to put out there so I decided to let you guys do the same if you want, who knows, maybe someone can do it on a bigger scale than I did :doge:


A bit of a background about this so you have some kind of understanding.
I have set up a backend listener that will listen to the sockets coming in and the Twitter API is accessed through the backend only because OSBot blocks it for some reason.

The host is the IP of a server that I have and this is the only thing that will be running on that server. Don't change the IP/Port if you want to access it through my backend. 


Twitter has some rules about using their API and there is some information on how to get your API/Access Keys and Tokens on the website. You should read this before using the code.

Underneath is the src to the front-end that you'd need to implement into your scripts or anything else for that matter if you wanted to use it.

 

Example usage:

    public static void main(String[] args) {
        final Twitter twitter = new Twitter();
        twitter.setTwitterKeys("", "");
        twitter.setTwitterTokens("", "");
        System.out.println(twitter.sendTweetRequest("TEST"));
    }

 

Twitter Class:

package main;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.Socket;

public class Twitter {

    private String apiKey;
    private String secretKey;

    private String secretToken;
    private String accessToken;

    private String host = "62.171.157.14";
    private int port = 42069;

    public void setTwitterKeys(final String apiKey, final String secretKey) {
        this.apiKey = apiKey;
        this.secretKey = secretKey;
    }

    public void setTwitterTokens(final String accessToken, final String secretToken) {
        this.secretToken = secretToken;
        this.accessToken = accessToken;
    }

    public void setSocketDestination(final String host, final int port) {
        this.host = host;
        this.port = port;
    }

    public String sendTweetRequest(final String content) {
        String resp = null;
        if (isInfoNull()) {
            System.out.println("Info is null..set the required info before continuing...");
        } else {
            try {
                Socket socket = new Socket(host, port);
                PrintWriter out = new PrintWriter(socket.getOutputStream());

                out.println(apiKey + "--" + secretKey + "--" + accessToken + "--" + secretToken + "--" + content + "--");
                out.flush();

                BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream()));

                resp = in.readLine();
                socket.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return resp;
    }

    private boolean isInfoNull() {
        return apiKey == null || secretKey == null || accessToken == null || secretToken == null || host == null || port == -1;
    }
}
  • Like 1
  • Boge 2
Link to comment
Share on other sites

  • 1 month later...

Funny troll lol

 

Also just some food for thought: those variables ie. api keys and tokens  are necessary for the Twitter class to do its job, so they would probably be better off being passed in via the Constructor as opposed to using setters later on.

 

**Also would be cautions to anyone blindly passing their personal api tokens/secrets to some unknown backend** Not to say you're doing anything malicious at the other end of that socket but just pointing that out lol

Edited by Mom
Link to comment
Share on other sites

13 hours ago, Mom said:

Also just some food for thought: those variables ie. api keys and tokens  are necessary for the Twitter class to do its job, so they would probably be better off being passed in via the Constructor as opposed to using setters later on.

 

**Also would be cautions to anyone blindly passing their personal api tokens/secrets to some unknown backend** Not to say you're doing anything malicious at the other end of that socket but just pointing that out lol


I did it this way so it wasn't one massive line of code to create the class instance :doge:

Also you are correct about the API/Tokens etc, however, I think the risk would be extremely low. It's not like I can use their accounts to promote doubling BTC or anything :doge:

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...