Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require_once 'TwistOAuth.php';
- // APIキー設定
- $ck = '';
- $cs = '';
- $ot = '';
- $os = '';
- // リクエスト設定
- $slug = ''; // リスト名
- $owner_screen_name = ''; // 所持者のスクリーンネーム
- $count = 30; // フォロワーの最新何件を対象にするか
- $stringify_ids = true; // True固定
- // テキストとしてデータを表示
- header('Content-Type: text/plain; charset=utf-8');
- try {
- // TwistOAuthのインスタンス生成
- $to = new TwistOAuth($ck, $cs, $ot, $os);
- // フォロワーID一覧の取得
- $ids = $to->get('followers/ids', compact('count', 'stringify_ids'))->ids;
- // リスト追加のためのcURLリソースの生成
- $curls = [];
- foreach ($ids as $i => $id) {
- $curls[$i] = $to->curlPost('lists/members/create', compact('user_id', 'owner_screen_name', 'slug'));
- }
- // 並列実行して結果表示
- foreach ($to->curlMultiExec($curls) as $i => $response) {
- if ($response instanceof stdClass) {
- echo "{$ids[$i]}: 成功\n";
- } else {
- echo "{$ids[$i]}: 失敗({$response->getMessage()})\n";
- }
- }
- } catch (TwistException $e) {
- // フォロワー一覧取得失敗時など
- echo 'エラー: ' . $e->getMessage();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement