éªãã ãªãã
æ¨å¤å¯ãå¯ãã¨è¨ã£ã¦ããããä»æèµ·ãããå¤ãç½ãã¦ã³ã£ããã
ã»ã¨ãã©æº¶ãããã£ãæ§ãªç¶æ
ãªã®ã§ãå±æ ¹ããéªããã©ã³ãã«æ»ãè½ã¡ã¦ãããã¾ããé³ãä¸ããã
ãããªææã«éªããµããã¨ããããã ã
æ±äº¬ã§ãã®ææã®éªã¯41å¹´ã¶ããããã¦ããã³ããå¬ç¨ã®ã³ã¼ããã¯ãªã¼ãã³ã°ã«åºãã¦ãªãã¦ããã£ãããã£ã¨ããæ£ç¢ºã«è¨ãã¨ã¯ãªã¼ãã³ã°ã«åºããã¨å¿ããªãããã«ä½åº¦ãçé¢ã®ã¯ãªã¼ãã³ã°ç¨ç´è¢ã«å
¥ãããã¨ã¯ãã£ãã®ã ããæã家ãåºãææ®ã®å¤å¯ããã¨ãä½åº¦ããã£ã¦è¢ããåãåºãã¦ããã®ã ãã©ã
Twitter APIã¨PEAR::Services::Twitterã§å ¨ãã©ãã¯ã¼ã®æ å ±ãåå¾
Twitter APIãéãã¦ãããã¦ã¼ã¶ã®å
¨ãã©ãã¯ã¼ãåå¾ãããã¨æã£ãã以ä¸ã®æ§ãªå½¢ã«ãªãã
ããã§ã¯ãã¹ã¯ãªã¼ã³åã¨è¨å®ãã¦ããã¢ã¤ã³ã³ã®ä¿ç®¡ä½ç½®ãåå¾ãã¦ããã
ãã½ã¨è¨ãããã§ã¯ãªããã$info = $twitter->statuses->followers(array("cursor" => -1)); ã¨ããªãã¨ããã©ãã¯ã¼ã®äººæ°ã100人ãè¶
ããå ´åã«ç¶ãã¦ãã¼ã¿ãåå¾ããããã®cursorã®å¤ãåããªãã
æåè¨å®ããªãã§ãcursorã®å¤ãåãã大ãã«æ©ãã ã
åç §: Twitter REST API Method: statuses followers
<?php require_once 'Services/Twitter.php'; require_once 'HTTP/OAuth/Consumer.php'; $consumerkey = ""; // Twitterããéçºè ãåå¾ããConsumer keyãè¨å® $consumersecret = ""; // Twitterããéçºè ãåå¾ããSecret keyãè¨å® $accesstoken = ""; // Twitterã®OAuthèªè¨¼ã§å¾ã¦ããAccess Token $accessecret = ""; // Twitterã®OAuthèªè¨¼ã§å¾ã¦ããAccess Token Secret try{ $twitter = new Services_Twitter(); $oauth = new HTTP_OAuth_Consumer($consumerkey, $consumersecret, $accesstoken, $accessecret); $twitter->setOAuth($oauth); $followerprop_ary = array(); $cursor = -1; do{ $info = $twitter->statuses->followers(array("cursor" => $cursor)); foreach($info->users as $follower){ $tmp = array( "screen_name" => $follower->screen_name, "profile_img" => $follower->profile_image_url, ); $followerprop_ary[] = $tmp; } $cursor = $info->next_cursor_str; }while($cursor != "0"); print_r($followerprop_ary); printf("Total %d followers.\n", count($followerprop_ary)); } catch (Services_Twitter_Exception $e) { echo $e->getMessage(); } ?>