【发布时间】:2016-10-26 23:58:40
【问题描述】:
在我的应用程序中,我有 3 种不同的方式来使用 Instagram Auth,并且需要根据操作重定向到 3 个不同的位置。因此,我有 3 个不同的身份验证网址
我注册的重定向网址是http://nameoftheapp.com/folder/
验证 URL 1 是
https://api.instagram.com/oauth/authorize/?client_id='
+ ig_id
+ '&response_type=code&redirect_uri='
+ encodeURI('http://nameoftheapp.com/folder/?l=r');
验证 URL 2 是
https://api.instagram.com/oauth/authorize/?client_id='
+ ig_id
+'&response_type=code&redirect_uri='
+ encodeURI('http://nameoftheapp.com/folder/?l=g');
验证 URL 3 是
https://api.instagram.com/oauth/authorize/?client_id='
+ ig_id
+'&response_type=code&redirect_uri='
+ encodeURI('http://nameoftheapp.com/folder/?l=l');
现在所有这些 URL 都将我返回到正确的 URL,并附加了代码,准备好转换为访问令牌。
没有 EncodeURI 中的参数,这让我可以访问我需要的数据。如果我保留这些参数,我会收到下面的 HTTP400 错误
[23-Aug-2014 10:26:40 Europe/Berlin] Array
(
[code] => 400
[error_type] => OAuthException
[error_message] => Redirect URI doesn't match original redirect URI
)
如果您查看 Instagram 文档上的此页面,它会说它允许您使用参数 http://instagram.com/developer/authentication/
【问题讨论】:
-
不是参数,我认为是
encodeURI()故障jsfiddle.net/zzkw0o9u也许你只需要编码参数值,而不是完整的URI
标签: instagram