-
Notifications
You must be signed in to change notification settings - Fork 106
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from Sifchain/pollCreation
[Twitter] Added Generalizable V2 API with examples starting with Polls
- Loading branch information
Showing
10 changed files
with
802 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,13 @@ | ||
# for v1 api support | ||
TWITTER_USERNAME=myaccount | ||
TWITTER_PASSWORD=MyPassword!!! | ||
TWITTER_EMAIL=[email protected] | ||
PROXY_URL= # HTTP(s) proxy for requests (optional) | ||
|
||
# for v2 api support | ||
TWITTER_API_KEY=key | ||
TWITTER_API_SECRET_KEY=secret | ||
TWITTER_ACCESS_TOKEN=token | ||
TWITTER_ACCESS_TOKEN_SECRET=tokensecret | ||
|
||
# optional | ||
PROXY_URL= # HTTP(s) proxy for requests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { Scraper } from 'agent-twitter-client'; | ||
import dotenv from 'dotenv'; | ||
dotenv.config(); | ||
|
||
async function main() { | ||
// const scraper = new Scraper(); | ||
// // v1 login | ||
// await scraper.login( | ||
// process.env.TWITTER_USERNAME, | ||
// process.env.TWITTER_PASSWORD, | ||
// ); | ||
// // v2 login | ||
// await scraper.login( | ||
// process.env.TWITTER_USERNAME, | ||
// process.env.TWITTER_PASSWORD, | ||
// undefined, | ||
// undefined, | ||
// process.env.TWITTER_API_KEY, | ||
// process.env.TWITTER_API_SECRET_KEY, | ||
// process.env.TWITTER_ACCESS_TOKEN, | ||
// process.env.TWITTER_ACCESS_TOKEN_SECRET, | ||
// ); | ||
// console.log('Logged in successfully!'); | ||
// // Example: Posting a new tweet with a poll | ||
// await scraper.sendTweetV2( | ||
// `When do you think we'll achieve AGI (Artificial General Intelligence)? 🤖 Cast your prediction!`, | ||
// undefined, | ||
// { | ||
// poll: { | ||
// options: [ | ||
// { label: '2025 🗓️' }, | ||
// { label: '2026 📅' }, | ||
// { label: '2027 🛠️' }, | ||
// { label: '2030+ 🚀' }, | ||
// ], | ||
// durationMinutes: 1440, | ||
// }, | ||
// }, | ||
// ); | ||
// console.log(await scraper.getTweet('1856441982811529619')); | ||
// const tweet = await scraper.getTweetV2('1856441982811529619'); | ||
// console.log({ tweet }); | ||
// console.log('tweet', tweet); | ||
// const tweets = await scraper.getTweetsV2([ | ||
// '1856441982811529619', | ||
// '1856429655215260130', | ||
// ]); | ||
// console.log('tweets', tweets); | ||
} | ||
|
||
main(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.