public function testGetGravatarUrlNotExistingEmail() { $picUrl = "http://www.gravatar.com/avatar/b4b5e684119038eca5b9ccf84d594d03?s=200&d=mm&r=r"; $avatarUrl = GravatarHelper::getGravatarUrl("*****@*****.**"); $pic = base64_encode($this->http->get($avatarUrl)); $this->assertNotNull($avatarUrl); $this->assertNotNull($pic); $this->assertEqual($picUrl, $avatarUrl, "URLs should match"); }
/** * Returns a user identified by his specific secret. * * @param string $secret The user's secret. * * @return the JSON encoded user information */ public function getUserBySecret($secret) { if (!empty($secret)) { $this->getDbProxy()->setWhere("secret = '" . $secret . "'"); $userData = json_decode($this->getDbProxy()->select(), true); $userData = $userData[0]; if (!empty($userData)) { if (!isset($_SESSION)) { session_start(); } $_SESSION['secret'] = $secret; $_SESSION['user_id'] = $userData['id']; if (empty($userData['pic_url'])) { $userData['pic_url'] = GravatarHelper::getGravatarUrl($userData['oauth_user_id']); } $userData['logged_in'] = true; return json_encode($userData); } } return $this->getDefaultUserJson(); }
/** * Adds picture from Gravatar if "pic_url" is empty. * * @param array $score The score data. * * @return array the $score array with the replaced field */ protected static function setPicUrl(array $score) { if (empty($score['pic_url'])) { $score['pic_url'] = GravatarHelper::getGravatarUrl($score['oauth_user_id']); } unset($score['oauth_user_id']); return $score; }