private function parseUser($entry) { $user = new TwitterUser(); $user->setUserID($entry['id_str']); $user->setName('@' . $entry['screen_name']); $user->setImageURL(ImageLoader::cacheImage(IS_SECURE ? $entry['profile_image_url_https'] : $entry['profile_image_url'], array())); return $user; }
public function getUser($login) { if (empty($login)) { return new AnonymousUser(); } //use the cache if available if ($this->useCache) { $cacheFilename = "user_$login"; if ($this->cache === NULL) { $this->cache = new DiskCache(CACHE_DIR . "/Twitter", $this->cacheLifetime, TRUE); $this->cache->setSuffix('.json'); $this->cache->preserveFormat(); } if ($this->cache->isFresh($cacheFilename)) { $data = $this->cache->read($cacheFilename); } else { //cache isn't fresh, load the data if ($data = $this->oauthRequest('GET', $this->API_URL .'/users/show.json', array('screen_name'=>$login))) { $this->cache->write($data, $cacheFilename); } } } else { //load the data $data = $this->oauthRequest('GET', $this->API_URL . '/users/show.json', array('screen_name'=>$login)); } // make the call if ($data) { $json = @json_decode($data, true); if (isset($json['screen_name'])) { $user = new TwitterUser($this); $user->setTwitterUserID($json['id']); $user->setUserID($json['screen_name']); $user->setFullName($json['name']); return $user; } } return false; }