示例#1
0
 public function createFriendship($Model, $screenName)
 {
     return $this->_Twitter->createFriendship($screenName);
 }
 function resetFriends($deleteAll = false)
 {
     require_once PATH_CORE . '/utilities/twitter.php';
     $tObj = new Twitter(TWITTER_USER, TWITTER_PWD, $this->db);
     if ($deleteAll) {
         $resp = $tObj->getFriendIds(TWITTER_USER);
         foreach ($resp as $id) {
             $tObj->deleteFriendship($id);
         }
     }
     $mt = new microAccountsTable($this->db);
     $ma = $mt->getRowObject();
     $q = $this->db->query("SELECT * FROM MicroAccounts WHERE sid=0;");
     while ($d = $this->db->readQ($q)) {
         $ma->load($d->id);
         $this->db->log('Process:' . $ma->shortName);
         if ($ma->sid == 0) {
             if ($tObj->existsFriendship(TWITTER_USER, $d->shortName)) {
                 $resp = $tObj->getFriendship(TWITTER_USER, $d->shortName);
                 $resp = $tObj->getUser($resp['target']['id']);
             } else {
                 $resp = $tObj->createFriendship($d->shortName);
             }
             if ($resp !== false) {
                 $this->db->log($resp);
                 $ma->sid = $resp['id'];
                 $ma->friendlyName = $resp['name'];
                 $ma->profile_image_url = $resp['profile_image_url'];
                 $ma->update();
             } else {
                 $this->db->log('FALSE');
             }
         }
     }
 }