如何解决Instagram的“代码”和“重定向网址”是什么?
我正在开发具有Instagram集成的应用程序。为此,我使用了GitHub项目jInstagram(https://github.com/sachin-handiekar/jInstagram)。
如果要登录Instagram,则必须设置重定向URL。我的第一个问题是:此URL的作用是什么?我没有找到有关此的详细信息。 jInstagram中的代码如下:
InstagramService service = new InstagramAuthService()
.apiKey("your_client_id")
.apiSecret("your_client_secret")
.callback("your_callback_url")
.build();
来源:https://github.com/sachin-handiekar/jInstagram/wiki/jInstagram-Usage
要获取访问令牌,我必须创建一个验证程序并从中生成一个访问令牌。在jInstagram的用法中,有关该验证程序的唯一信息是:
Verifier verifier = new Verifier("verifier you get from the user");
Token accessToken = service.getAccessToken(EMPTY_TOKEN,verifier);
来源:https://github.com/sachin-handiekar/jInstagram/wiki/jInstagram-Usage
我必须传递给验证者的构造函数什么?我搜索了一个答案,发现必须在代码示例中传递一个名为“ code”的请求参数:https://github.com/sachinhandiekar/jInstagramexamples/blob/master/src/main/java/com/sachinhandiekar/examples/InstagramTokenHandler.java
private static final String CODE = "code";
protected void doGet(HttpServletRequest request,HttpServletResponse response) throws javax.servlet.ServletException,IOException {
String code = request.getParameter(CODE);
InstagramService service = (InstagramService) request.getServletContext().getAttribute(Constants.INSTAGRAM_SERVICE);
Verifier verifier = new Verifier(code);
Token accessToken = service.getAccessToken(verifier);
Instagram instagram = new Instagram(accessToken);
HttpSession session = request.getSession();
session.setAttribute(Constants.INSTAGRAM_OBJECT,instagram);
System.out.println(request.getContextPath());
// Redirect to User Profile page.
response.sendRedirect(request.getContextPath() + "/profile.jsp");
}
这是什么代码?我如何拥有它?
感谢您阅读此问题。我期待得到答案。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。