Give me a simple way to post a tweet via the API
No bounty left

I have been trying to figure out how to build a Twitter bot for a while. I had it almost done, then Elon went and wrecked their API for no good reason and I had to start over. Their API is a complete mess and makes me appreciate the simplicity of the Manifold one much more. I'm really tired of dealing with it.

I don't need anything fancy, I just want a Javascript function that I can call with my API key/secret and will immediately post a top-level tweet. Installing an npm library is fine. M$500 to the first person who provides such a function that just works with no additional fiddling necessary.

Get
Ṁ1,000
to start trading!
Sort by:

const { TwitterApi } = require('twitter-api-v2');

async function postTweet(content, apiKey, apiSecret, accessToken, accessSecret) {

const client = new TwitterApi({

appKey: apiKey,

appSecret: apiSecret,

accessToken: accessToken,

accessSecret: accessSecret,

});

try {

const tweet = await client.v2.tweet(content);

console.log("Tweet posted successfully:", tweet);

} catch (error) {

console.error("Error posting tweet:", error);

}

}

// Usage

const apiKey = 'YOUR_API_KEY';

const apiSecret = 'YOUR_API_SECRET';

const accessToken = 'YOUR_ACCESS_TOKEN';

const accessSecret = 'YOUR_ACCESS_SECRET';

postTweet("Hello, Twitter!", apiKey, apiSecret, accessToken, accessSecret);

© Manifold Markets, Inc.Terms + Mana-only TermsPrivacyRules