android: how to get user photos in Instagram?

后端 未结 2 1021
囚心锁ツ
囚心锁ツ 2021-02-01 11:30

In my app my requirement is to get the user photos and show in my app.

For that i am authenticate , got access token and enter username password but that shows you don\'

相关标签:
2条回答
  • 2021-02-01 12:00

    try this code i got solution from this:

     URL example = new URL("https://api.instagram.com/v1/users/self/media/recent?access_token="
                                + accessToken);
    
                URLConnection tc = example.openConnection();
                BufferedReader in = new BufferedReader(new InputStreamReader(
                        tc.getInputStream()));
    
                String line;
                while ((line = in.readLine()) != null) {
                    JSONObject ob = new JSONObject(line);
    
                    JSONArray object = ob.getJSONArray("data");
    
                    for (int i = 0; i < object.length(); i++) {
    
    
                        JSONObject jo = (JSONObject) object.get(i);
                        JSONObject nja = (JSONObject) jo.getJSONObject(photos);
    
                        JSONObject purl3 = (JSONObject) nja
                                .getJSONObject("thumbnail");
                        Log.i(TAG, "" + purl3.getString("url"));
                    }
    
                }
            } catch (MalformedURLException e) {
    
                e.printStackTrace();
            } catch (IOException e) {
    
                e.printStackTrace();
            } catch (JSONException e) {
    
                e.printStackTrace();
            }
    
        }
    
    0 讨论(0)
  • 2021-02-01 12:02

    GET /users/[USER_ID]/media/recent/?access_token=[ACCESS_TOKEN]

    You can hit this URL to get the user's feed (last 20 photos). This will give you a JSON array that you will then need to parse and display as desired in your app.

    0 讨论(0)
提交回复
热议问题