简体   繁体   English

重定向Ajax后获取URL

[英]Get url after redirect Ajax

To authenticate on Instagram I need to get an url sent me by Instagram as a redirect. 要在Instagram上进行身份验证,我需要获取一个由Instagram发送给我的URL作为重定向。 I need to get the redirected url but I obtain ever null. 我需要获取重定向的URL,但我永远都为null。

$.ajax({
url: "https://instagram.com/oauth/authorize/?client_id=e40f15a90**c89851d8a66&redirect_uri=http://examle.com&response_type=token",

success:function(result,status,xhr){
console.log(xhr.getResponseHeader('Location'));<---NULL
}

});

You can't get header info after redirect that would happen as a result of the request. 重定向后,您将无法获取标头信息,该信息可能是由于请求而导致的。 Standard way is to open new child window with auth url (" https://instagram.com/oauth/authorize/?client_id=...response_type=token ", ) and retrieve token in redirect url, for example in onready event of http://examle.com after that send token to parent window and close popup (child) window. 标准方法是使用auth url(“ https://instagram.com/oauth/authorize/?client_id=...response_type=token “,)打开新的子窗口,并在重定向url中检索令牌,例如在以下情况的onready事件中:之后将http://examle.com发送令牌到父窗口并关闭弹出(子)窗口。

Recommended Instagram auth is server side, so consider to use it. 推荐的Instagram身份验证在服务器端,因此请考虑使用它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM