twitter自動リムーブ(オートアンフォロー)機能を追加したので解説
4 1月
EasyBotterを使って自動リムーブ
参考サイト
EasyBotter
自動リムーブスクリプト
ステップ①
EasyBotterを設定します。
以下参考
大まかな流れ ①ファイルをダウンロードする ②エディタを使って、ダウンロードしたファイルにbotのユーザー名、 パスワードなどの設定や、botに発言させたい内容を書き込む ③編集したファイルをサーバーにアップロードする ④アップロードしたプログラムを定期的に実行する
ステップ②
壊れたカメラと壊れたボクも、トコシエに。さんが作った自動リムーブスクリプトを使います。
○EasyBotter.phpに追加するスクリプト
// 片思い自動リムーブ
function autoRemove() {
//フォロワーのidを全取得
$response = $this->getfollowerids();
$followList = array();
foreach($response as $id){$followList[] = $id;}
//フォローのidを全取得
$response = $this->getfriendsids();
$friendsList = array();
foreach($response as $id){$friendsList[] = $id;}
//片想いの人を$removeへ
$remove = array_diff($friendsList, $followList);
$remove_count = "0"; //おまじない
if ( !empty($remove) ) {
foreach($remove as $id){
$remove_count++;
//リムーブします。
$removereq = $this->consumer
->sendRequest("http://twitter.com/friendships/destroy/$id.json",array(),"POST");
}
}
echo $remove_count."人をリムーブしました。";
}
function getfollowerids() {
$url = "http://api.twitter.com/1/followers/ids/[あなたのBOTのTwitterのID].xml";
return $this->_getData($url);
}
function getfriendsids() {
$url = "http://api.twitter.com/1/friends/ids/[あなたのBOTのTwitterのID].xml";
return $this->_getData($url);
}
○新規ファイル制作。(remove.php)
?php
//=============================
//EasyBotterを呼び出します
//=============================
require_once("EasyBotter.php");
$eb = new EasyBotter();
$response = $eb->autoRemove();
?>
ステップ③
自動リムーブを実行する。
サーバー上のEasyBotter.phpと同じ場所に「remove.php」をアップロードし、ブラウザからremove.phpにアクセスしてください。
「〇〇人をリムーブしました。」と表示されれば成功です。
OAuthに関してはこのあたりを参考にして下さい。
おすすめ関連記事
twitterで特定のキーワードをつぶやいた人を自動でフォローする設定にしたので解説
twitter自動リムーブ(オートアンフォロー)機能を追加したので解説
5分で出来るさくらサーバーでcronの設定をする方法
参考書籍
|
|
IT&LifeのニュースをFacebookで配信しています。
時間のないビジネスマンにおすすめです。是非イイネ!でチェックを!
