-
Notifications
You must be signed in to change notification settings - Fork 2
/
pickme-cli.php
executable file
·47 lines (35 loc) · 1.3 KB
/
pickme-cli.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php
require 'config.php';
use \DMS\Service\Meetup\MeetupKeyAuthClient;
$seconds_to_run = 10;
$time_between_name_flash = 125000; //in microseconds
$screen_width = 80; //If terminal font is large, this should be reduced.
// Clear your screen
passthru('clear');
// Add you Meetup.com API Key
$client = MeetupKeyAuthClient::factory(array('key' => $config['meetup_api']));
// Put the Event ID that you want to pull the RSVP list from
// Event ID can be pulled from the URL of the Event on MeetUp if needed
$event_id = readline("Please Enter Your Event ID>> ");
$meetup_rsvps = $client->getRSVPs(array('event_id' => $event_id));
// Clear your screen
passthru('clear');
$rsvps = array();
foreach ($meetup_rsvps as $rsvp) {
$rsvps[] = $rsvp;
}
$start_time = time();
$seconds = 0;
while ($seconds < $seconds_to_run) {
shuffle($rsvps);
$seconds = time() - $start_time;
$max_name_width = $screen_width - strlen($seconds) - 3;
$name = substr($rsvps[0]['member']['name'], 0, $max_name_width);
$name = str_pad($name, $max_name_width);
print "\r" . str_repeat(' ', $screen_width) . "\r";
print "$seconds - " . $name;
usleep($time_between_name_flash);
}
print "\r" . str_repeat(' ', $screen_width) . "\r";
print "The winner is" . str_repeat(' ', 80) . "\n";
print $rsvps[0]['member']['name'] . "\n";