9
9
use HabboAPI \HabboParser ;
10
10
11
11
// Create new Parser and API instance
12
- $ habboParser = new HabboParser ($ _SERVER [ ' SERVER_ADDR ' ], 'https://www.habbo.com/api/public/ ' );
12
+ $ habboParser = new HabboParser ('https://www.habbo.com/api/public/ ' );
13
13
$ habboApi = new HabboAPI ($ habboParser );
14
14
15
15
// Find the user 'koeientemmer' and get their ID
23
23
$ myProfile = array ('habbo ' => $ myHabbo );
24
24
}
25
25
26
- // Print all the $profile data in a pretty format
27
- $ lastSection = '' ;
26
+ // Export as HTML
27
+ $ html = [
28
+ 'habbo ' => '' ,
29
+ 'worn_badges ' => '' ,
30
+ 'friends ' => '' ,
31
+ 'groups ' => '' ,
32
+ 'rooms ' => '' ,
33
+ 'badges ' => ''
34
+ ];
35
+
36
+ // Print all the $profile data in a pretty format, except for 'habbo'
37
+ $ lastSection = 'habbo ' ;
28
38
foreach ($ myProfile as $ section => $ data ) {
29
39
30
40
// Print section name
31
41
if ($ section != $ lastSection ) {
32
42
$ lastSection = $ section ;
33
- echo '<h2> ' . ucfirst ($ section ). ' ( ' . count ($ data ). ')</h2> ' ;
43
+ $ html [ $ section ] .= '<h2> ' . ucfirst ($ section ) . ' ( ' . count ($ data ) . ')</h2> ' ;
34
44
}
35
45
36
46
// Some markup for the Habbo part
37
47
if ($ section == 'habbo ' ) {
38
48
/* @var Habbo $habbo */
39
49
$ habbo = $ data ;
40
- echo '<img src="http://www.habbo.com/habbo-imaging/avatarimage?figure= ' . $ habbo ->getFigureString (). '&size=m &gesture=sml&head_direction=3"
41
- alt=" '. $ habbo ->getHabboName (). '" title=" ' . $ habbo ->getHabboName (). '" style="float: left; margin-right: 10px;" /> ' ;
42
- echo '<h3> ' . $ habbo ->getHabboName (). '</h3> ' ;
43
- echo '<p> ' . $ habbo ->getMotto (). '<br><em> ' . date ('d-M-Y ' , strtotime ($ habbo ->getMemberSince ())). '</em></p> ' ;
50
+ $ html [ ' habbo ' ] .= '<img src="http://www.habbo.com/habbo-imaging/avatarimage?figure= ' . $ habbo ->getFigureString () . '&size=l &gesture=sml&head_direction=3"
51
+ alt=" ' . $ habbo ->getHabboName () . '" title=" ' . $ habbo ->getHabboName () . '" style="float: left; margin-right: 10px;" /> ' ;
52
+ $ html [ ' habbo ' ] .= '<h3> ' . $ habbo ->getHabboName () . '</h3> ' ;
53
+ $ html [ ' habbo ' ] .= '<p> ' . $ habbo ->getMotto () . '<br><em> ' . date ('d-M-Y ' , strtotime ($ habbo ->getMemberSince ())) . '</em></p> ' ;
44
54
if ($ habbo ->getProfileVisible ()) {
45
- echo '<p><a href="https://www.habbo.com/profile/ ' . $ habbo ->getHabboName (). '">View home »</a></p> ' ;
55
+ $ html [ ' habbo ' ] .= '<p><a href="https://www.habbo.com/profile/ ' . $ habbo ->getHabboName () . '">View home »</a></p> ' ;
46
56
}
47
57
if ($ badges = $ habbo ->getSelectedBadges ()) {
48
58
foreach ($ badges as $ badge ) {
49
59
/** @var Badge $badge */
50
- echo
51
- '<p>
52
- <img src="http://images.habbo.com/c_images/album1584/ ' .$ badge ->getCode ().'.gif" alt=" ' .$ badge ->getName ().'" title=" ' .$ badge ->getName ().'" /><br>
53
- <strong> ' .$ badge ->getName ().'</strong><br>
54
- <em> ' .$ badge ->getDescription ().'</em>
55
- </p>
56
- ' ;
60
+ $ html ['worn_badges ' ] .=
61
+ '
62
+ <div class="media">
63
+ <div class="media-left media-middle">
64
+ <a href="#">
65
+ <img class="media-object" src="http://images.habbo.com/c_images/album1584/ ' . $ badge ->getCode () . '.gif" alt=" ' . $ badge ->getName () . '">
66
+ </a>
67
+ </div>
68
+ <div class="media-body">
69
+ <h4 class="media-heading"> ' . $ badge ->getName () . '</h4>
70
+ <em> ' . $ badge ->getDescription () . '</em>
71
+ </div>
72
+ </div>
73
+ ' ;
74
+ }
75
+ }
76
+ } else {
77
+ // Show all the other sections as an unordered list
78
+ if (in_array ($ section , array ("friends " , "groups " , "rooms " , "badges " ))) {
79
+ $ html [$ section ] .= '<ul> ' ;
80
+ foreach ($ data as $ object ) {
81
+ $ html [$ section ] .= '<li> ' . $ object . '</li> ' ; // uses the __toString() method
57
82
}
83
+ $ html [$ section ] .= '</ul> ' ;
58
84
}
59
85
}
86
+ }
87
+ ?>
88
+ <!DOCTYPE html>
89
+ <html lang="en">
90
+ <head>
91
+ <meta charset="utf-8">
92
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
93
+ <meta name="viewport" content="width=device-width, initial-scale=1">
94
+ <title>HabboAPI</title>
60
95
61
- // Show all the other sections as an unordered list
62
- if (in_array ($ section , array ("friends " , "groups " , "rooms " , "badges " ))) {
63
- echo '<ul> ' ;
64
- foreach ($ data as $ object ) {
65
- echo '<li> ' .$ object .'</li> ' ; // uses the __toString() method
96
+ <link href="http://bootswatch.com/lumen/bootstrap.min.css" rel="stylesheet">
97
+ <style type="text/css">
98
+ html, body {
99
+ margin: 20px;
66
100
}
67
- echo '</ul> ' ;
68
- }
69
- }
101
+ .media-left {
102
+ min-width: 60px;
103
+ }
104
+ </style>
105
+
106
+ <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
107
+ <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
108
+ <!--[if lt IE 9]>
109
+ <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
110
+ <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
111
+ <![endif]-->
112
+ </head>
113
+ <body>
114
+
115
+ <div class="container">
116
+
117
+ <div class="jumbotron">
118
+ <h1>HabboAPI</h1>
119
+
120
+ <p>A PHP wrapper library for the undocumented API of Habbo</p>
121
+
122
+ <p><a class="btn btn-primary btn-lg" href="https://github.com/gerbenjacobs/HabboAPI" role="button" target="_blank">Learn more</a></p>
123
+ </div>
124
+
125
+ <div class="row">
126
+ <div class="col-md-6">
127
+ <?php echo $ html ['habbo ' ]; ?>
128
+ </div>
129
+ <div class="col-md-6">
130
+ <?php echo $ html ['worn_badges ' ]; ?>
131
+ </div>
132
+ </div>
133
+
134
+ <?php if ($ myHabbo ->hasProfile ()): ?>
135
+ <div class="row">
136
+ <div class="col-md-3">
137
+ <?php echo $ html ['badges ' ]; ?>
138
+ </div>
139
+ <div class="col-md-3">
140
+ <?php echo $ html ['friends ' ]; ?>
141
+ </div>
142
+ <div class="col-md-3">
143
+ <?php echo $ html ['groups ' ]; ?>
144
+ </div>
145
+ <div class="col-md-3">
146
+ <?php echo $ html ['rooms ' ]; ?>
147
+ </div>
148
+ </div>
149
+ <?php endif ; ?>
150
+ </div>
151
+
152
+ <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
153
+ <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
154
+ </body>
155
+ </html>
0 commit comments