ܻؤ1顪30奵꡼ޥܥ

ITȤƯ30奵꡼ޥΥ饤ߥ󥰵Ͽ

Twitter

äĴ٤뤳ȤäΤǡȤƻĤƤޤ

ܸtweetˡϤȤ⤦ɡ
ϥեAPIǥ桼κǿΥơ뤳Ȥ顢
ͭ̾ͤΥեtweet򽸤ʿͤФƤߤ褦ȡ

֤׳ŪˤɤΤ餤tweetʿͤȤפȤƿѤǤͤȤäƤϤ͡
ä褦ʽʤä褦ʵ뤱ɡȤꤢŬʿȤäƤߤޤ

åȤȤͭ̾ͤϾ֤
֤ΥեAPIǼʿͤޤ

äȸŤAPIλ͸Ƥpage=1Ȥǥڡꤹäƽ񤤤ƤɡΥɥȸcursorˤʤäƤ
̵̤˥ϥޤä

ͤcursor=-1ꤷơ쥹ݥ󥹤next_cursor֤äƤΤǼΥڡ򸫤ȤϤͤꤹ롣
פcursor=1,2,3Ȥʤߤ

˽񤤤ƤñʥХåäƤߤȤ
оTweet6587tweet
ȡʸ234153ʸ
ʿTweetʸ35.5ʸ
ʾΤ褦ʷ̤ˡ
*)RTǻϤޤäƤtweetϽޤ

٤äƤߤƤ30ʸäΤǡ
ܿͤ3040ʸǤĤ֤䤤ƤǤ礦֤

tweetLength.php

<?php
$username = "USERNAME";
$password = "PASSWORD";
$target = 'kazuyo_k';

$tweet=0;
$length=0;
$cursor = -1;
for ($i=0;$i<150;$i++) {
  if ($cursor == 0) break 1;

  $url = sprintf("http://twitter.com/statuses/followers.json?cursor=%d&screen_name=%s",$cursor,$target);
  $json = request($url,$username,$password);
  if (!is_array($json->users)) continue 1;
  foreach ($json->users as $key => $val) {
    if(isset($val->status)) {
      //RTǻϤޤtweetФ
      if(preg_match("/^RT(.+)/",$val->status->text)) continue 1;

      if (mb_detect_encoding($val->status->text) != 'UTF-8') continue 1;
      $tweet++;
      $length+=mb_strlen($val->status->text, 'utf-8');
    }
  }
  $cursor = $json->next_cursor;
}
echo "tweet  : " . $tweet . "\n";
echo "length : " . $length . "\n";
echo "avg    : " . $length / $tweet . "\n";

function request($host='',$username='',$password=''){
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL, $host);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
  curl_setopt($ch, CURLOPT_USERPWD, "$username:$password");
  curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
  $result = curl_exec($ch);
  curl_close($ch);

  return json_decode($result);
}
?>
    Υȥ꡼ϤƤʥ֥åޡɲ

ɤTwitterڤ٤
ʤˤڤΤޤ褯狼Τ
ʬǶ̣Ƥ褦APIȤäƥȺޤ
CakePHPͤơ

ECôäݤߤפ򥭡ɤ˽Ƥߤޤ

Ȥꤢ֤äѤʤߤǺäΤȤ겡ʴǤ


˾ʤ

˾ʤ

åäꡢ⤦äȥꥢ륿Ȳ¿ȻפΤǤܤܤޤ
    Υȥ꡼ϤƤʥ֥åޡɲ

TwitterAPI˸ɤꤲɽΥץ롣

ꥯȥѥ᡼ΰ㡣
ܺ٤Ϥ򻲾
q
callbackХåؿꤷȤ
langоݤθ
rpp븡̿
pageڡ


쥹ݥ󥹥ǡϤʤ󤸡
created_atȯ
from_user桼ID
profile_image_url桼Υץե
textȯ

³ƥȥץ롣
³ɤ
    Υȥ꡼ϤƤʥ֥åޡɲ

ΥڡΥȥåץ