コード例 #1
0
 function run()
 {
     $cache = new FileCache();
     $box = $cache->get(self::TWITTER_CRAWL_KEY);
     if (!is_array($box)) {
         $box = array();
     }
     $api = new TwitterApi(HIDETOBARA_OAUTH_KEY, HIDETOBARA_OAUTH_SECRET);
     $a = $api->getHomeTimeline($box);
     $storage = new TwitterStorage();
     $storage->retrieveStatus($a);
     $storage->saveStatusByDate(LOG_DIR . "status/");
     $box = $storage->updateUserCache($box);
     $cache->set(self::TWITTER_CRAWL_KEY, $box);
 }
コード例 #2
0
 private function reply()
 {
     $generator = new ReplyState($this->name);
     $generator->load();
     $box = $this->cache->get($this->cacheKeyLastStatus());
     $timelines = $this->twitter->getHomeTimeline($box);
     $storage = new TwitterStorage();
     $storage->retrieveStatus($timelines);
     foreach ($storage->listStatus as $status) {
         if ($this->isMyTweet($status)) {
             continue;
         }
         if ($this->isSpecialTweet($status) && $this->invoker(5) || $this->isReplyTweetForMe($status)) {
             $best = $generator->generate($status->text);
             if ($best['to']) {
                 $best['text'] = "@" . $status->user->screen_name . " " . $best['to'];
                 $best['reply_to'] = $status->id;
                 $this->postTalk($best);
                 break;
             }
         }
     }
     $this->cache->set($this->cacheKeyLastStatus(), $storage->updateUserCache($box));
 }