本文整理汇总了Golang中github.com/laicosly/goth.User类的典型用法代码示例。如果您正苦于以下问题:Golang User类的具体用法?Golang User怎么用?Golang User使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了User类的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: userFromReader
func userFromReader(reader io.Reader, user *goth.User) error {
u := struct {
ID string `json:"id"`
//Email string `json:"email"`
//Bio string `json:"bio"`
Name string `json:"name"`
Link string `json:"link"`
/*Picture struct {
Data struct {
URL string `json:"url"`
} `json:"data"`
} `json:"picture"`
Location struct {
Name string `json:"name"`
} `json:"location"`*/
}{}
err := json.NewDecoder(reader).Decode(&u)
if err != nil {
return err
}
user.Name = u.Name
//user.NickName = u.Name
//user.Email = u.Email
//user.Description = u.Bio
//user.AvatarURL = u.Picture.Data.URL
user.UserID = u.Name //u.ID
//user.Location = u.Location.Name
return err
}
开发者ID:laicosly,项目名称:goth,代码行数:33,代码来源:reddit.go
示例2: userFromReader
func userFromReader(r io.Reader, user *goth.User) error {
u := struct {
Country string `json:"country"`
DisplayName string `json:"display_name"`
Email string `json:"email"`
ID string `json:"id"`
Images []struct {
URL string `json:"url"`
} `json:"images"`
}{}
err := json.NewDecoder(r).Decode(&u)
if err != nil {
return err
}
user.Name = u.DisplayName
user.Email = u.Email
user.UserID = u.ID
user.Location = u.Country
if len(u.Images) > 0 {
user.AvatarURL = u.Images[0].URL
}
return nil
}
开发者ID:laicosly,项目名称:goth,代码行数:25,代码来源:spotify.go
示例3: userFromReader
func userFromReader(reader io.Reader, user *goth.User) error {
u := struct {
Data struct {
UserID string `json:"id"`
AvatarURL string `json:"image"`
Description string `json:"bio"`
FirstName string `json:"first_name"`
LastName string `json:"last_name"`
NickName string `json:"username"`
} `json:"data"`
}{}
err := json.NewDecoder(reader).Decode(&u)
if err != nil {
return err
}
user.NickName = u.Data.NickName
user.UserID = u.Data.UserID
user.Name = fmt.Sprintf("%s %s", u.Data.FirstName, u.Data.LastName)
user.Description = u.Data.Description
user.AvatarURL = u.Data.AvatarURL
return err
}
开发者ID:laicosly,项目名称:goth,代码行数:26,代码来源:pinterest.go
示例4: FetchUser
// FetchUser will go to Tumblr and access basic information about the user.
func (p *Provider) FetchUser(session goth.Session) (*goth.User, error) {
user := goth.User{}
sess := session.(*Session)
response, err := p.consumer.Get(
endpointProfile,
map[string]string{
"method": "flickr.people.getInfo",
"format": "json",
"nojsoncallback": "1",
"user_id": sess.AccessToken.AdditionalData["user_nsid"],
},
sess.AccessToken)
if err != nil {
return nil, err
}
defer response.Body.Close()
bits, err := ioutil.ReadAll(response.Body)
err = json.NewDecoder(bytes.NewReader(bits)).Decode(&user.RawData)
if err != nil {
return nil, err
}
user.AccessToken = sess.AccessToken.Token
user.AccessTokenSecret = sess.AccessToken.Secret
err = userFromReader(bytes.NewReader(bits), &user)
return &user, err
}
开发者ID:laicosly,项目名称:goth,代码行数:29,代码来源:flickr.go
示例5: userFromReader
func userFromReader(reader io.Reader, user *goth.User) error {
u := struct {
Person struct {
Id string `json:"nsid"`
Location struct {
Content string `json:"_content"`
} `json:"location"`
Name struct {
Content string `json:"_content"`
} `json:"realname"`
Username struct {
Content string `json:"_content"`
} `json:"username"`
} `json:"person"`
}{}
err := json.NewDecoder(reader).Decode(&u)
if err != nil {
return err
}
user.Name = u.Person.Name.Content
user.UserID = u.Person.Id
user.NickName = u.Person.Username.Content
return err
}
开发者ID:laicosly,项目名称:goth,代码行数:26,代码来源:flickr.go
示例6: userFromReader
func userFromReader(reader io.Reader, user *goth.User) error {
u := struct {
Data struct {
ID string `json:"id"`
Username string `json:"username"`
//Email string `json:"email"`
Name string `json:"full_name"`
Bio string `json:"bio"`
Picture string `json:"profile_picture"`
Website string `json:"website"`
Counts struct {
Media int `json:"media"`
Follows int `json:"follows"`
FollowedBy int `json:"followed_by"`
} `json:"counts"`
} `json:"data"`
}{}
err := json.NewDecoder(reader).Decode(&u)
if err != nil {
return err
}
user.Name = u.Data.Name
user.NickName = u.Data.Username
//user.Email = u.Data.Email
user.Description = u.Data.Bio
user.AvatarURL = u.Data.Picture
user.UserID = u.Data.ID
//user.Location =
return err
}
开发者ID:laicosly,项目名称:goth,代码行数:34,代码来源:instagram.go
示例7: FetchUser
// FetchUser will go to Twitter and access basic information about the user.
func (p *Provider) FetchUser(session goth.Session) (*goth.User, error) {
sess := session.(*Session)
response, err := p.consumer.Get(
endpointProfile,
map[string]string{"include_entities": "false", "skip_status": "true"},
sess.AccessToken)
if err != nil {
return nil, err
}
defer response.Body.Close()
bits, err := ioutil.ReadAll(response.Body)
if err != nil {
return nil, err
}
user := goth.User{}
err = json.NewDecoder(bytes.NewReader(bits)).Decode(&user.RawData)
if err != nil {
return nil, err
}
user.Name = user.RawData["name"].(string)
user.NickName = user.RawData["screen_name"].(string)
user.Description = user.RawData["description"].(string)
user.AvatarURL = user.RawData["profile_image_url"].(string)
user.UserID = user.RawData["id_str"].(string)
user.Location = user.RawData["location"].(string)
user.AccessToken = sess.AccessToken.Token
user.AccessTokenSecret = sess.AccessToken.Secret
return &user, err
}
开发者ID:laicosly,项目名称:goth,代码行数:32,代码来源:twitter.go
示例8: userFromReader
func userFromReader(reader io.Reader, user *goth.User) error {
u := struct {
ID string `json:"user_id"`
Username string `json:"user"`
}{}
err := json.NewDecoder(reader).Decode(&u)
if err != nil {
return err
}
user.NickName = u.Username
user.UserID = u.ID
return err
}
开发者ID:laicosly,项目名称:goth,代码行数:17,代码来源:slack.go
示例9: userFromReader
func userFromReader(reader io.Reader, user *goth.User) error {
u := struct {
ID int `json:"id"`
Email string `json:"email"`
Bio string `json:"bio"`
Name string `json:"name"`
Picture string `json:"avatar_url"`
Location string `json:"location"`
}{}
err := json.NewDecoder(reader).Decode(&u)
if err != nil {
return err
}
user.Name = u.Name
user.NickName = u.Name
user.Email = u.Email
user.Description = u.Bio
user.AvatarURL = u.Picture
user.UserID = strconv.Itoa(u.ID)
user.Location = u.Location
return err
}
开发者ID:laicosly,项目名称:goth,代码行数:25,代码来源:github.go
示例10: userFromReader
func userFromReader(reader io.Reader, user *goth.User) error {
u := struct {
ID string `json:"id"`
Email string `json:"emailAddress"`
FirstName string `json:"firstName"`
LastName string `json:"lastName"`
Headline string `json:"headline"`
PictureURL string `json:"pictureUrl"`
Location struct {
Name string `json:"name"`
} `json:"location"`
}{}
err := json.NewDecoder(reader).Decode(&u)
if err != nil {
return err
}
user.Name = u.FirstName + " " + u.LastName
user.NickName = u.FirstName
user.Email = u.Email
user.Description = u.Headline
user.AvatarURL = u.PictureURL
user.UserID = u.ID
user.Location = u.Location.Name
return err
}
开发者ID:laicosly,项目名称:goth,代码行数:29,代码来源:linkedin.go
示例11: userFromReader
func userFromReader(reader io.Reader, user *goth.User) error {
u := struct {
ID int `json:"uid"`
Email string `json:"email"`
Name string `json:"display_name"`
Country string `json:"country"`
}{}
err := json.NewDecoder(reader).Decode(&u)
if err != nil {
return err
}
user.Name = u.Name
user.Email = u.Email
user.UserID = strconv.Itoa(u.ID)
user.Location = u.Country
return err
}
开发者ID:laicosly,项目名称:goth,代码行数:21,代码来源:dropbox.go
示例12: userFromReader
func userFromReader(reader io.Reader, user *goth.User) error {
u := struct {
Response struct {
User struct {
//ID string `json:"id"`
//Username string `json:"username"`
//Email string `json:"email"`
Name string `json:"name"`
} `json:"user"`
} `json:"response"`
}{}
err := json.NewDecoder(reader).Decode(&u)
if err != nil {
return err
}
user.Name = u.Response.User.Name
user.UserID = u.Response.User.Name
return err
}
开发者ID:laicosly,项目名称:goth,代码行数:21,代码来源:tumblr.go
示例13: userFromReader
func userFromReader(reader io.Reader, user *goth.User) error {
u := struct {
ID int `json:"id"`
Permalink string `json:"permalink"`
Username string `json:"username"`
Description string `json:"description"`
Picture string `json:"avatar_url"`
Name string `json:"full_name"`
Country string `json:"country"`
City string `json:"city"`
}{}
err := json.NewDecoder(reader).Decode(&u)
if err != nil {
return err
}
user.Name = u.Name
user.NickName = u.Username
user.Description = u.Description
user.AvatarURL = u.Picture
user.UserID = strconv.Itoa(u.ID)
user.Location = u.City + " " + u.Country
return err
}
开发者ID:laicosly,项目名称:goth,代码行数:27,代码来源:soundcloud.go
示例14: userFromReader
func userFromReader(reader io.Reader, user *goth.User) error {
u := struct {
UserID int `json:"ID"`
AvatarURL string `json:"avatar_URL"`
Email string `json:"email"`
Description string `json:"profile_URL"`
Name string `json:"username"`
NickName string `json:"display_name"`
}{}
err := json.NewDecoder(reader).Decode(&u)
if err != nil {
return err
}
user.NickName = u.NickName
user.UserID = strconv.Itoa(u.UserID)
user.Name = u.Name
user.Description = u.Description
user.AvatarURL = u.AvatarURL
user.Email = u.Email
return err
}
开发者ID:laicosly,项目名称:goth,代码行数:25,代码来源:wordpress.go
示例15: FetchUser
// FetchUser will go to Tumblr and access basic information about the user.
func (p *Provider) FetchUser(session goth.Session) (*goth.User, error) {
user := goth.User{}
sess := session.(*Session)
response, err := p.consumer.Get(
endpointProfile,
map[string]string{},
sess.AccessToken)
if err != nil {
return nil, err
}
defer response.Body.Close()
bits, err := ioutil.ReadAll(response.Body)
err = json.NewDecoder(bytes.NewReader(bits)).Decode(&user.RawData)
if err != nil {
return nil, err
}
user.AccessToken = sess.AccessToken.Token
user.AccessTokenSecret = sess.AccessToken.Secret
err = userFromReader(bytes.NewReader(bits), &user)
return &user, err
}
开发者ID:laicosly,项目名称:goth,代码行数:24,代码来源:tumblr.go
示例16: userFromReader
func userFromReader(reader io.Reader, user *goth.User) error {
u := struct {
ID string `json:"id"`
Email string `json:"email"`
Name string `json:"name"`
Link string `json:"link"`
Picture string `json:"picture"`
}{}
err := json.NewDecoder(reader).Decode(&u)
if err != nil {
return err
}
user.Name = u.Name
user.NickName = u.Name
user.Email = u.Email
//user.Description = u.Bio
user.AvatarURL = u.Picture
user.UserID = u.ID
//user.Location = u.Location.Name
return err
}
开发者ID:laicosly,项目名称:goth,代码行数:24,代码来源:gplus.go
示例17: FetchUser
// FetchUser will go to LastFM and access basic information about the user.
func (p *Provider) FetchUser(session goth.Session) (*goth.User, error) {
sess := session.(*Session)
user := goth.User{AccessToken: sess.AccessToken}
u := struct {
XMLName xml.Name `xml:"user"`
Id string `xml:"id"`
Name string `xml:"name"`
RealName string `xml:"realname"`
Url string `xml:"url"`
Country string `xml:"country"`
Age string `xml:"age"`
Gender string `xml:"gender"`
Subscriber string `xml:"subscriber"`
PlayCount string `xml:"playcount"`
Playlists string `xml:"playlists"`
Bootstrap string `xml:"bootstrap"`
Registered struct {
Unixtime string `xml:"unixtime,attr"`
Time string `xml:",chardata"`
} `xml:"registered"`
Images []struct {
Size string `xml:"size,attr"`
Url string `xml:",chardata"`
} `xml:"image"`
}{}
login := session.(*Session).Login
err := p.request(false, map[string]string{"method": "user.getinfo", "user": login}, &u)
if err == nil {
user.Name = u.RealName
user.NickName = u.Name
user.AvatarURL = u.Images[3].Url
user.UserID = u.Id
user.Location = u.Country
}
return &user, err
}
开发者ID:laicosly,项目名称:goth,代码行数:41,代码来源:lastfm.go
注:本文中的github.com/laicosly/goth.User类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论