Okhttp

Okhttp POST

FormBody body = new FormBody.Builder()
            .add("client_id", "732455797163076")
            .add("client_secret", "c62af5089291c704126536193d8009a5")
            .add("grant_type", "authorization_code")
            .add("redirect_uri", redirectUri)
            .add("code", code)
            .build();

    Request request = new Request.Builder()
            .url("https://api.instagram.com/oauth/access_token")
            .post(body)
            .build();

    new OkHttpClient().newCall(request).enqueue(new Callback() {
        @Override
        public void onFailure(Call call, IOException e) {
            Log.d("social", "onFailure: ");
        }

        @Override
        public void onResponse(Call call, Response response) throws IOException {
            Log.d("social", "onFailure:" + response.body().string());
        }
    });

發表迴響