GithubHelp home page GithubHelp logo

sadeghpro / tweetfree Goto Github PK

View Code? Open in Web Editor NEW

This project forked from face-hh/tweetfree

0.0 0.0 0.0 30 KB

Twitter's API made free using puppeteer

License: Apache License 2.0

JavaScript 100.00%

tweetfree's Introduction

tweetfree

Twitter's API, reconstructed utilizing puppeteer for emulating user behavior, for free.

Features: tweet, heart, retweet, user info, tweet listener based on mentions;

As seen on YouTube

Usage

Boilerplate:

    const tweetfree = require('./index');
    const tweetListener = require('./utils/search')
    // enable debug to see what's happening in the browser via GUI
    const client = new tweetfree({ debug: false });

    await client.init();
    await client.login({
        email: '',
        password: '',
        username: ''
    });

    console.log('Logged in!')

    await client.tweet({ content: 'this is a test' })
    await client.tweet({ content: 'second test' })

    // 2nd param is post id 
    await client.execute('heart', { user: 'elonmusk', id: '1619770090530181120' })
    await client.execute('retweet', { user: 'elonmusk', id: '1619770090530181120' })

    const data = await client.getUser({ user: 'elonmusk' });
    // {
    //   followers: '127.8M',
    //   following: '177',
    //   joinedAt: 'June 2009',
    //   tweets: '22.5K Tweets',
    //   verified: true
    // }
    console.log(data)

    // "3000" - the delay between each search fetch
    const tweetEmitter = new tweetListener(client, 3000);

    tweetEmitter.on('tweetCreate', async (tweet) => {
        // destroy the listener after receiving 1 tweet
        // WARNING: you will receive 20~ of the current tweets mentioning the username
        // WARNING: ^^ when running for the first time

        await tweetEmitter.stopListening();

        // create a tweet
        await client.tweet({ content: `hello ${tweet.author}, i have received your tweet saying: ${tweet.content}, turns out it had mentioned: ${tweet.mentioned}`})
    })
    // keep track of the stopping reason
    tweetEmitter.on('stop', ((reason) => console.log(reason)))

The code doesn't keep track of sessions?

Yes, the code isn't able to receive the auth_token cookie becauase it's a HTTPOnly cookie. These can only be accessed via the extension APIs, therefore:

  • install EditThisCookie
  • log into twitter;
  • open the extension;
  • click the export icon;
  • paste the code inside cookies.json.

Or, let the code log in everytime (might make your account look sus, amogus if you will.)

Warning

The code was written purely for fun, not suited for big projects due to the limitations caused by the fact that it only works in 1 tab.

Feel free to modify the code to your desired needs, as it's made easy to do so.

License

Free as long as you credit me :)

tweetfree's People

Contributors

face-hh avatar compeydev avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.