Last active
October 21, 2016 10:58
-
-
Save mpyw/0e03985d7bc72376164351ce569b888d to your computer and use it in GitHub Desktop.
最近のついったーはいじんどをしらべるよ
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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