我使用此代码向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做到这一点?
答案 0 :(得分:1)
尝试查看本教程:
Asynchronous HTTP Requests in Android Using Volley 我在第一次在项目上应用凌空时使用了这个。 Volley非常简单易用。