用android volley获取Instagram访问令牌

时间:2015-03-15 12:12:31

标签: android instagram access-token android-volley

我使用此代码向Instagram发送请求并获取accessstoken。

URL url = new URL(tokenURLString);
            HttpsURLConnection httpsURLConnection = (HttpsURLConnection) url.openConnection();
            httpsURLConnection.setRequestMethod("POST");
            httpsURLConnection.setDoInput(true);
            httpsURLConnection.setDoOutput(true);
            OutputStreamWriter outputStreamWriter = new OutputStreamWriter(httpsURLConnection.getOutputStream());
            outputStreamWriter.write("client_id="+CI +
                    "&client_secret="+ CS +
                    "&grant_type=authorization_code" +
                    "&redirect_uri="+CALLBACK_URL+
                    "&code=" + requestToken);
            outputStreamWriter.flush();
            JSONObject jsonObject = new JSONObject(StreamToString.get(httpsURLConnection.getInputStream()));

如何用android volley做到这一点?

1 个答案:

答案 0 :(得分:1)

尝试查看本教程:

Asynchronous HTTP Requests in Android Using Volley 我在第一次在项目上应用凌空时使用了这个。 Volley非常简单易用。