function cleanUpFollows()
 {
     $fd = new FollowDAO($this->db, $this->logger);
     $continue_fetching = true;
     while ($this->api->available && $this->api->available_api_calls_for_crawler > 0 && $continue_fetching) {
         $oldfollow = $fd->getOldestFollow();
         $friendship_call = $this->api->cURL_source['show_friendship'];
         $args = array();
         $args["source_id"] = $oldfollow["followee_id"];
         $args["target_id"] = $oldfollow["follower_id"];
         list($cURL_status, $twitter_data) = $this->api->apiRequest($friendship_call, $this->logger, $args);
         if ($cURL_status == 200) {
             try {
                 $friendship = $this->api->parseXML($twitter_data);
                 if ($friendship['source_follows_target'] == 'true') {
                     $fd->update($oldfollow["followee_id"], $oldfollow["follower_id"]);
                 } else {
                     $fd->deactivate($oldfollow["followee_id"], $oldfollow["follower_id"]);
                 }
                 if ($friendship['target_follows_source'] == 'true') {
                     $fd->update($oldfollow["follower_id"], $oldfollow["followee_id"]);
                 } else {
                     $fd->deactivate($oldfollow["follower_id"], $oldfollow["followee_id"]);
                 }
             } catch (Exception $e) {
                 $status_message = 'Could not parse friendship XML';
             }
         } else {
             $continue_fetching = false;
         }
     }
 }
Exemple #2
0
 function testGetOldestFollow()
 {
     $q = "INSERT INTO tt_follows (user_id, follower_id, last_seen, active) VALUES (930061, 20, '2001-04-08 23:54:41', 1);";
     $this->db->exec($q);
     $dao = new FollowDAO($this->db, $this->logger);
     $oldest_follow = $dao->getOldestFollow();
     $this->assertTrue($oldest_follow != null);
     $this->assertEqual($oldest_follow["followee_id"], 930061);
     $this->assertEqual($oldest_follow["follower_id"], 20);
 }