4
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

NodeJSのtwitterモジュールで自動フォロバ

Last updated at Posted at 2017-05-16

注意

短時間にたくさんの人にフォローされると
その分、フォローバックしてしまうので、
凍結される可能性があります。

自己責任でご使用ください

概要

NodeJSのTwitterモジュールで自動フォロバをする
サンプルがなくて、少しハマったので書いておく。

ソース

const twitter = require('twitter');

client.stream('user', function(stream) {
  stream.on('follow', function(data) {
    if (data.source.id_str=="myId") return;
    client.post('friendships/create', {user_id:data.source.id_str});
  });
});

followイベントは自分が誰かをフォローした時と誰かにフォローされた時に着火する
なので自分が誰かをフォローすると自分で自分をフォローするというよくわからない状態になってしまうので
if (data.source.id_str=="myId") return;
で対象が自分の場合を除外する

4
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?