Ejemplo n.º 1
0
func GetUserPhoto(photoResp *fb.Result, context appengine.Context) *image.Image {
	var dataField fb.Result
	photoResp.DecodeField("data", &dataField)

	var url string
	dataField.DecodeField("url", &url)

	client := urlfetch.Client(context)
	resp, err := client.Get(url)
	data, err := ioutil.ReadAll(resp.Body)
	resp.Body.Close()
	check(err, context)

	reader := bytes.NewReader(data)
	profilePicture, _, err := image.Decode(reader)
	check(err, context)

	return &profilePicture
}
Ejemplo n.º 2
0
func SaveAboutUser(aboutResp *fb.Result, party string, context appengine.Context) {
	var log Log
	aboutResp.Decode(&log)

	var ageRange map[string]int
	var location map[string]string
	aboutResp.DecodeField("location", &location)
	aboutResp.DecodeField("age_range", &ageRange)

	log.AgeRange = ageRange["min"]
	log.Location = location["name"]
	log.Party = party

	_, err := datastore.Put(context,
		datastore.NewIncompleteKey(context, "log", nil),
		&log)
	check(err, context)
}