[英]Why i can't get parameters from the url sent by Facebook after '#' character
I'm trying to make login to facebook according to Facebook Server-Side Authentication flow using jsp and servlets. 我正在尝试使用jsp和servlet根据Facebook服务器端身份验证流程登录到facebook。 I was succsessfuly login to my fb account but when fb is redirecting to my app, it sends the parameters (state...) after the character '#'.
我成功登录了我的fb帐户,但是当fb重定向到我的应用程序时,它将在字符“#”后发送参数(状态...)。 I was looking at this: http://facebook.stackoverflow.com/questions/4144878/get-url-parameters-after-in-java .
我正在看这个: http : //facebook.stackoverflow.com/questions/4144878/get-url-parameters-after-in-java 。
but i'm doing it in a different way then they do. 但是我用与他们不同的方式来做。
here's my code: 这是我的代码:
response.sendRedirect(response.encodeRedirectURL("http://www.facebook.com/dialog/oauth/?client_id=343473222406382" +
"&redirect_uri=http://localhost:8080/accountsLogger&response_type=token&state=logged"));
and i'm redirecting to: 我将重定向到:
{http://localhost:8080/accountsLogger/#state=logged&access_token=AAAE4YxdpUO4BAILjJoj5GsFZBDir1YmZCy4ZC9BmZAOCAztC2QclKo46OSce7dzObL6lSzrYpRDgQycOzzhfbqThR6kVC16lmurC5X5oV1lIrsvI0h9D&expires_in=4329.}
The FB API is built (largely) to be used client-side. FB API的构建(大部分)是在客户端使用的。 The hash-portion of the URL (what is after the '#') is never sent to the server by the browser (which is why you can't pick it up).
URL的哈希部分(“#”之后的内容)永远不会通过浏览器发送到服务器(这就是为什么您无法选择它)。 If you need this information server-side, you need to pick it up using javascript on your accountsLogger page (
document.location.hash
), convert the "hash parameters" into "regular" url-parameters on another URL and redirect the page to that URL. 如果需要服务器端此信息,则需要在accountLogger页面(
document.location.hash
)上使用javascript进行提取,将“哈希参数”转换为另一个URL上的“常规” URL参数,然后将页面重定向至该网址。
URL after #
is not sent to the server. #
之后的URL不会发送到服务器。 It's originally intended as an anchor, it is, something to refer on the downloaded page. 它最初是作为锚定的,它是要在下载页面上引用的内容。 The browser then do:
浏览器然后执行:
GET /your/url.htm?param1=value¶m2=value
and if there's #someanchor
at the end the browser tries to position the page to make that anchor visible (if it exists). 如果
#someanchor
处有#someanchor
,则浏览器会尝试定位页面以使该锚可见(如果存在)。
Old school anchor: 老派主播:
<a name="someanchor">Hello</a>
Standard HTML anchor: 标准HTML锚点:
<p id="someanchor">Hello</p>
(thanks @Jon Hanna) <p id="someanchor">Hello</p>
(感谢@Jon Hanna)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.