Golang Facebook Graph API App Engine -
i'm using huandu/facebook golang access fb api. https://github.com/huandu/facebook
this works locally when try run google app engine environment, can't run.
i used code locally:
res, err := fb.get("/me", fb.params{ "fields": "id,first_name,last_name,name", "access_token": usertoken, })
in documentation (link above) mention app engine environment can'f figure out how ge work fb.get convention.
thanks.
edit
almost got work!:
// create global app var hold app id , secret. var globalapp = fb.new("<appid>", "<appsecret>") session := globalapp.session(usertoken) //user token here context := appengine.newcontext(r) //not sure r should be... session.httpclient = urlfetch.client(context) res, err := session.get("/me", nil) if err := json.newencoder(w).encode(res); err != nil { panic(err) }
if id , name. need request other parameters. do in r parameter app engine context?
to answer last question asked, appengine.newcontext(r)
function takes *http.request
parameter, refers current request, 1 code executing in. can use r.url.query()
if wanted query parameters sent request.
if want send parameters in request, 1 facebook api, can include them directly in url pass session.get()
. can use url.values.encode
if want build query string map of values. if need make request using method other get, such api method expects json, can use http.newrequest eg.
session.httpclient = urlfetch.client(context) request, err := http.newrequest("put", url, strings.newreader("{ "someproperty": 1234 }")) response, err := session.do(request)
Comments
Post a Comment