我正在尝试将vk auth与martini一起使用。但是编译出错:/goPath/vkAuthTry2.go:38: undefined: YourRedirectFunc问题是如何定义YourRedirectFunc函数。或者,如果问得更广泛,我需要martini使用vk社交网络身份验证的应用程序示例,或者更广泛地使用vk身份验证的任何 golang 网站的示例。完整代码:package mainimport ( "github.com/go-martini/martini" "github.com/yanple/vk_api" "net/http")var api vk_api.Apifunc prepareMartini() *martini.ClassicMartini { m := martini.Classic() m.Get("/somePage", func(w http.ResponseWriter, r *http.Request) { // And receive token on the special method (redirect uri) currentUrl := r.URL.RequestURI() // for example "yoursite.com/get_access_token#access_token=3304fdb7c3b69ace6b055c6cba34e5e2f0229f7ac2ee4ef46dc9f0b241143bac993e6ced9a3fbc111111&expires_in=0&user_id=1" accessToken, userId, expiresIn, err := vk_api.ParseResponseUrl(currentUrl) if err != nil { panic(err) } api.AccessToken = accessToken api.UserId = userId api.ExpiresIn = expiresIn w.Write([]byte("somePage")) }) return m}func main() { authUrl, err := api.GetAuthUrl( "domain.com/method_get_access_token", // redirect URI "token", // response type "4672050", // client id "wall,offline", // permissions https://vk.com/dev/permissions ) if err != nil { panic(err) } YourRedirectFunc(authUrl) prepareMartini().Run()}
3 回答
- 3 回答
- 0 关注
- 150 浏览
添加回答
举报
0/150
提交
取消