Skip to main content

Black Friday 2025! Only until December 1st: coupon FRIDAY25 for 40% off Yearly/Lifetime membership!

Read more here

Gummibeer/gummibeer.de

11 stars
1 code files
View Gummibeer/gummibeer.de on GitHub

app/Console/Commands/TwitterGiveaway.php

Open in GitHub
use Illuminate\Console\Command;
use Illuminate\Support\Collection;
use Illuminate\Support\Str;
use stdClass;
 
class TwitterGiveaway extends Command
{
//
public function handle(Twitter $twitter): void
{
//
$ids = collect();
$cursor = -1;
do {
$response = $twitter->request(
sprintf('statuses/retweeters/ids.json?id=%s&count=100&stringify_ids=true&cursor=%d', $id, $cursor),
'GET'
);
$ids->push(...$response->ids);
$cursor = $response->next_cursor;
} while ($cursor != 0);
 
$users = $ids
->chunk(100)
->map(fn (Collection $ids): array => $twitter->request(
sprintf('users/lookup.json?user_id=%s', $ids->implode(',')),
'GET'
))
->collapse()
->map(fn (stdClass $user): string => $user->screen_name)
->push(...$added)
->reject(fn (string $username): bool => $excluded->contains($username))
->values();
//
}
//
}

We'd Love Your Feedback

Tell us what you like or what we can improve

Feel free to share anything you like or dislike about this page or the platform in general.