agent-twitter-client:无需Twitter API密钥,发送、转发推文

Últimas herramientas de IAActualizado hace 4 meses Sharenet.ai
850 0
吐司AI

Introducción general

agent-twitter-client是一个无需Twitter API密钥即可使用的Twitter客户端。该项目基于@the-convocation/twitter-scraper进行了修改,增加了发送推文和转推的功能。它可以在浏览器和服务器上运行,适用于需要自动化Twitter操作的用户。通过配置环境变量进行身份验证,用户可以轻松地发送推文、获取推文和进行其他Twitter操作。

agent-twitter-client:无需Twitter API密钥,发送、转发推文

 

Lista de funciones

  • 发送推文和转推
  • 获取特定用户的推文
  • 获取推文及其回复
  • 获取最新推文
  • 使用Twitter API v2进行推文和投票功能
  • 支持代理请求
  • 获取Twitter Cookies以避免频繁登录

 

Utilizar la ayuda

Proceso de instalación

  1. Almacén de proyectos de clonación:
   git clone https://github.com/elizaOS/agent-twitter-client.git
  1. Vaya al catálogo de proyectos:
   cd agent-twitter-client
  1. Instale la dependencia:
   npm install

Configuración de variables de entorno

在项目根目录下创建一个.env文件,并添加以下内容:

TWITTER_USERNAME=你的Twitter用户名
TWITTER_PASSWORD=你的Twitter密码
TWITTER_EMAIL=你的Twitter邮箱
PROXY_URL=你的代理URL(如果需要)
TWITTER_API_KEY=你的Twitter API密钥
TWITTER_API_SECRET_KEY=你的Twitter API密钥
TWITTER_ACCESS_TOKEN=你的Twitter访问令牌
TWITTER_ACCESS_TOKEN_SECRET=你的Twitter访问令牌密钥

使用示例

获取推文

const { Scraper } = require('agent-twitter-client');
const scraper = new Scraper();
(async () => {
await scraper.login('你的用户名', '你的密码');
const tweets = await scraper.getTweets('elonmusk', 10);
console.log(tweets);
})();

发送推文

const { Scraper } = require('agent-twitter-client');
const scraper = new Scraper();
(async () => {
await scraper.login('你的用户名', '你的密码');
await scraper.sendTweet('Hello world!');
})();

获取最新推文

const { Scraper } = require('agent-twitter-client');
const scraper = new Scraper();
(async () => {
await scraper.login('你的用户名', '你的密码');
const latestTweet = await scraper.getLatestTweet('elonmusk');
console.log(latestTweet);
})();

Funciones detalladas

  1. 发送推文和转推:用户可以通过配置环境变量进行身份验证,然后使用sendTweet方法发送推文,或使用sendRetweet方法进行转推。
  2. 获取推文: UsogetTweets方法可以获取特定用户的推文,getTweetsAndReplies方法可以获取推文及其回复。
  3. 获取最新推文: UsogetLatestTweet方法可以获取特定用户的最新推文。
  4. 使用Twitter API v2:通过配置Twitter API v2的密钥和令牌,用户可以使用sendTweetV2方法发送带有投票功能的推文。
  5. 代理请求:支持通过配置PROXY_URL环境变量来使用代理进行请求。
  6. 获取Twitter Cookies: UsogetCookies方法获取Twitter Cookies,以避免频繁登录。
© declaración de copyright
AiPPT

Artículos relacionados

Sin comentarios

ninguno
Sin comentarios...