Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace App\Console\Commands;

use Abraham\TwitterOAuth\TwitterOAuth;
use Illuminate\Console\Command;

class UpdateTwitterList extends Command
Expand Down Expand Up @@ -38,22 +37,10 @@ public function __construct()
*/
public function handle()
{
// You can get all these via https://dev.twitter.com/
$consumer_key = "";
$consumer_secret = "";
$access_token = "";
$access_token_secret = "";
$user_id = 0; // Twitter user ID
$connection = new TwitterOAuth(
$consumer_key,
$consumer_secret,
$access_token,
$access_token_secret
);
$user_id = config('services.twitter.user');
$connection = app('Twitter');
$list_id = config('services.twitter.list');

// Get our list
$lists = $connection->get("lists/list", ["user_id" => $user_id]);
$list = $lists[0]; // We only have one list, 'cycle'
$new_users = [];
$finished = false;
$raw_statuses = [];
Expand Down Expand Up @@ -172,7 +159,7 @@ public function handle()
echo "Grabbing users currently on our cycle list...\n";
$members = $connection->get(
"lists/members",
['list_id' => $list->id, 'count' => 5000]
['list_id' => $list_id, 'count' => 5000]
);
$users = $members->users;
$current_users = [];
Expand All @@ -199,7 +186,7 @@ public function handle()
$user_slice = array_slice($users_to_remove, $offset, 100);
$response = $connection->post(
"lists/members/destroy_all",
['list_id' => $list->id, 'user_id' => implode(",", $user_slice)]
['list_id' => $list_id, 'user_id' => implode(",", $user_slice)]
);

if ($connection->getLastHttpCode() !== 200) {
Expand Down Expand Up @@ -228,7 +215,7 @@ public function handle()
$user_slice = array_slice($users_to_add, $offset, 100);
$response = $connection->post(
"lists/members/create_all",
['list_id' => $list->id, 'user_id' => implode(",", $user_slice)]
['list_id' => $list_id, 'user_id' => implode(",", $user_slice)]
);

if ($connection->getLastHttpCode() !== 200) {
Expand Down