Example #1
0
func (this Facebooker) GetUserID(tok *oauth.Token) (result string) {
	oauther.GetSite(this, tok, "https://graph.facebook.com/me", func(res *http.Response) {
		//use json to read in the result into this struct
		var uid struct {
			ID string `json:"id"` //there are a lot of fields, but we really only care about the ID
		}

		d := json.NewDecoder(res.Body)
		err := d.Decode(&uid)
		if err != nil {
			panic(err)
		}

		result = uid.ID
	})
	return
}
Example #2
0
func (this GooglePlusser) GetUserID(tok *oauth.Token) (result string) {
	oauther.GetSite(this, tok, "https://www.googleapis.com/plus/v1/people/me?key="+this.apikey, func(res *http.Response) {
		//use json to read in the result, and get
		var uid struct {
			ID string `json:"id"` //this is really the only field we care about, we don't really care where people work or any of that shit
			//perhaps in the future, we will take in the age field or something, so we can get a better idea of who our demographics are and cater to them better
			//but for now, we don't really give a f**k
		}

		d := json.NewDecoder(res.Body)
		err := d.Decode(&uid)
		if err != nil {
			panic(err)
		}

		result = uid.ID
	})
	return
}