38 lines
844 B
Go
38 lines
844 B
Go
package roblox
|
|
|
|
import (
|
|
"encoding/json"
|
|
"io/ioutil"
|
|
)
|
|
|
|
type UserInfo struct {
|
|
UserID int `json:"UserID"`
|
|
UserName string `json:"UserName"`
|
|
RobuxBalance int `json:"RobuxBalance"`
|
|
TicketsBalance int `json:"TicketsBalance"`
|
|
ThumbnailURL string `json:"ThumbnailUrl"`
|
|
IsAnyBuildersClubMember bool `json:"IsAnyBuildersClubMember"`
|
|
}
|
|
|
|
// GetUserInfo will retrieve local user information
|
|
func (s *Session) GetUserInfo() (*UserInfo, error) {
|
|
resp, err := s.client.Get("http://www.roblox.com/mobileapi/userinfo")
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer resp.Body.Close()
|
|
|
|
data, err := ioutil.ReadAll(resp.Body)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
var info UserInfo
|
|
err = json.Unmarshal(data, &info)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return &info, nil
|
|
}
|