php - Posting to twitter from file -
i have such php script post twitter file:
function win2utf($s) { for($i=0, $m=strlen($s); $i<$m; $i++) { $c=ord($s[$i]); if ($c<=127) {$t.=chr($c); continue; } if ($c>=192 && $c<=207) {$t.=chr(208).chr($c-48); continue; } if ($c>=208 && $c<=239) {$t.=chr(208).chr($c-48); continue; } if ($c>=240 && $c<=255) {$t.=chr(209).chr($c-112); continue; } if ($c==184) { $t.=chr(209).chr(209); continue; }; if ($c==168) { $t.=chr(208).chr(129); continue; }; } return $t; } require_once 'options.php'; require_once 'twitteroauth/twitteroauth.php'; set_time_limit(0); $connection = new twitteroauth($options['consumer_key'], $options['consumer_secret'], $options['oauth_token'], $options['oauth_secret']); $connection->format = 'xml'; $lines = file(root.'inc/posts.txt'); $index = mt_rand(0, count($lines)-1); $status = win2utf($lines[$index]); $connection->post('statuses/update', array('status'=>$status));
how should improve script remove file messages i've posted already?
the best way move tweeted lines onto different file. 1 file have tweeted lines , 1 file have lines yet tweeted.
your function's readability isn't great way.
Comments
Post a Comment