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 (将#修改为@)