Skip to content

Instantly share code, notes, and snippets.

@mpyw
Last active October 21, 2016 10:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mpyw/0e03985d7bc72376164351ce569b888d to your computer and use it in GitHub Desktop.
Save mpyw/0e03985d7bc72376164351ce569b888d to your computer and use it in GitHub Desktop.
最近のついったーはいじんどをしらべるよ
<?php
function prompt($msg, $hidden = false) {
echo $msg;
if ($hidden) {
`stty -echo`;
}
$r = trim(fgets(STDIN));
if ($hidden) {
`stty echo`;
echo "\n";
}
return $r;
}
set_time_limit(0);
date_default_timezone_set('Asia/Tokyo');
eval('?>' . file_get_contents('https://raw.githubusercontent.com/mpyw/TwistOAuth/master/src/TwistOAuth.php'));
eval('?>' . file_get_contents('https://raw.githubusercontent.com/mpyw/TwistOAuth/master/src/TwistException.php'));
eval('?>' . file_get_contents('https://raw.githubusercontent.com/mpyw/TwistOAuth/master/src/TwistMedia.php'));
$to = TwistOAuth::login(
"iAtYJ4HpUVfIUoNnif1DA",
"172fOpzuZoYzNYaU3mMYvE8m8MEyLbztOdbrUolU",
prompt('SN: '),
prompt('PW: ', true)
);
$count = 200;
$max_id = null;
$list = [];
try {
while (true) {
foreach ($to->get('statuses/user_timeline', compact('count', 'max_id')) as $status) {
$list[] = date('m/d', strtotime($status->created_at));
}
$max_id = bcsub($status->id_str, '1');
}
} catch (TwistException $e) {}
$counts = array_count_values($list);
krsort($counts);
array_pop($counts);
$max_tweet = 5;
$status = '';
foreach ($counts as $date => $count) {
if ($max_tweet < 1) {
break;
}
$tmp = "$date: $count\n";
if (strlen($status . $tmp) > 140) {
$to->post('statuses/update', compact('status'));
$status = '';
--$max_tweet;
} else {
$status .= $tmp;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment