public function testCounts() { $counts = $this->profile->getCounts(); $this->assertEquals(1, $counts['habbo'], "Habbo count should be 1"); $this->assertEquals(203, $counts['badges'], "Badges count should be 203"); $this->assertEquals(9, $counts['groups'], "Groups count should be 9"); $this->assertEquals(147, $counts['friends'], "Friends count should be 147"); $this->assertEquals(5, $counts['rooms'], "Rooms count should be 5"); }
/** * Parses the Habbo Profile endpoints * * Return an associative array including a Habbo entity and 4 arrays with Group, Friend, Room, Badge entities * * @param string $id * @return array */ public function parseProfile($id) { // Collect JSON list($data) = $this->_callUrl($this->api_base . '/api/public/users/' . $id . '/profile', true); // Create Profile entity $profile = new Profile(); // Habbo $habbo = new Habbo(); $habbo->parse($data['user']); $profile->setHabbo($habbo); // Friends foreach ($data['friends'] as $friend) { $temp_friend = new Habbo(); $temp_friend->parse($friend); $profile->addFriend($temp_friend); } // Groups foreach ($data['groups'] as $group) { $temp_group = new Group(); $temp_group->parse($group); $profile->addGroup($temp_group); } // Rooms foreach ($data['rooms'] as $room) { $temp_room = new Room(); $temp_room->parse($room); $profile->addRoom($temp_room); } // Badges foreach ($data['badges'] as $badge) { $temp_badge = new Badge(); $temp_badge->parse($badge); $profile->addBadge($temp_badge); } // Return the Profile return $profile; }
echo ' <p>Oops. Can not find this Habbo!</p> <p>Try to catch this exception gracefully in your application!</p> <p>[' . $e->getCode() . '] ' . $e->getMessage() . '</p> <hr> ' . $e->getTraceAsString() . ' '; exit; } if ($myHabbo->hasProfile()) { // Collect all the profile info /** @var Profile $myProfile */ $myProfile = $habboApi->getProfile($myHabbo->getId()); } else { // This Habbo has a closed home, only show their Habbo object $profile = new Profile(); $myProfile = $profile->setHabbo($myHabbo); } $myPhotos = $habboApi->getPhotos($myHabbo->getId()); // Export as HTML $html = ['habbo' => '', 'worn_badges' => '', 'friends' => '', 'groups' => '', 'rooms' => '', 'badges' => '', 'photos' => '']; // Some markup for the Habbo part /* @var Habbo $habbo */ $habbo = $myProfile->getHabbo(); $html['habbo'] .= '<img src="http://www.habbo.com/habbo-imaging/avatarimage?figure=' . $habbo->getFigureString() . '&size=l&gesture=sml&head_direction=3" alt="' . $habbo->getHabboName() . '" title="' . $habbo->getHabboName() . '" style="float: left; margin-right: 10px;" />'; $html['habbo'] .= '<h3>' . $habbo->getHabboName() . '</h3>'; $html['habbo'] .= '<p>' . $habbo->getMotto() . '<br><em>' . $habbo->getMemberSince()->toFormattedDateString() . '</em></p>'; if ($habbo->getProfileVisible()) { $html['habbo'] .= '<p><a href="https://www.habbo.com/profile/' . $habbo->getHabboName() . '">View home »</a></p>'; }