4

我正在尝试为 facebook 建立一个登录链接,但我只在某些情况下遇到错误。我正在尝试在redirect_uri令牌中指定一个查询字符串参数,以便在登录后可以将它们重定向回我网站的特定区域。这是有效的和无效的。

&redirect_uri=http://mydomain.com/login?returnUrl=returnUrl- 有效 - &redirect_uri=http://mydomain.com/login?returnurl=/return/url无效 -&redirect_uri=http%3a%2f%2fmyagentcheckin.com%2flogin%3freturnUrl%3d%2freturn%2furl无效

似乎/查询字符串中的 导致它失败。Facebook 在我尝试时返回错误。有人知道解决这个问题的方法吗?

4

4 回答 4

5

不要将 returnUrl 参数包含在您的 redirect_uri 值中,而是使用 state 参数来存储此数据。

例如,

https://graph.facebook.com/oauth/authorize?type=web_server&client_id= {appid}&redirect_uri=http://www.yoursite.com/oauth/handshake&state=/requested/page

于 2011-06-30T20:43:44.103 回答
1

我经历过类似的事情,尤其是上面的多次重定向。

我的解决方案是将 returnUrl 放入用户的会话(或者可能是一个 cookie)中,这样我就不必为双重编码而苦苦挣扎。对于redirect_url,只需省略查询字符串。

于 2011-04-21T17:36:41.037 回答
0

Try using this API that put together. It will remove the hassle of this for you.

No url encoding necessary.

Sample Authentication

Imports Branches.FBAPI
...
Dim SI As New SessionInfo("[application_id]","applicaiton_secret")
SI.AuthenticateUser("http://[my url]", New SessionInfo.PermissionsEnum(){SessionInfo.PermissionsEnum.email, SessionInfo.PermissionsEnum.read_stream}))

Read the response from the URL you provided above from that page.

Dim FSR = FS.ReadFacebooAuthResponse
于 2011-04-23T14:22:29.947 回答
0

当我尝试你所做的事情时,我得到了一个类似这样的重定向回调。 http://mydomain.com/login?returnurl=%2Freturn%2Furl&code= ...

我解码“returnurl”值。然后它对我来说很好。

于 2011-04-25T00:41:37.530 回答