4 Replies - 182 Views - Last Post: 07 July 2019 - 12:50 PM

#1 [email protected]   User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 174
  • Joined: 24-February 15

RapidApi Instagram

Posted 05 July 2019 - 05:38 AM

I'm a little bit lost with reading API using java in android studio, I looked up some tutorials but can't figure out how exactly to make a beginning to read data from an Instagram feed.

I already made an account and a new user on developer page for Instagram and I want to make use of the rapid API, but can't figure out where I get this code from https://imgur.com/MSjOmGN

I don't need log in I just want users to open my app and photos will be loaded into the grid view from this Instagram I connect with, probably I will use a library for the grid view but that's another case.

If someone could guide me through this process, please.

Is This A Good Question/Topic? 0
  • +

Replies To: RapidApi Instagram

#2 rohshall   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 15-October 08

Re: RapidApi Instagram

Posted 05 July 2019 - 08:09 AM

Whenever you want to develop for some APIs, add "java client" to your search string. Most APIs will provide easy to use java client for their APIs to make develop's task easier. So, search for "instagram rapid API java client", and you will find it.
Was This Post Helpful? 0
  • +
  • -

#3 [email protected]   User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 174
  • Joined: 24-February 15

Re: RapidApi Instagram

Posted 06 July 2019 - 03:16 PM

Aah, I finally figured out how to get the authentication key.
What do I do next? I'm new with reading API with Java.
Was This Post Helpful? 0
  • +
  • -

#4 macosxnerd101   User is online

  • Games, Graphs, and Auctions
  • member icon




Reputation: 12618
  • View blog
  • Posts: 45,779
  • Joined: 27-December 08

Re: RapidApi Instagram

Posted 06 July 2019 - 03:55 PM

Moved to Android.
Was This Post Helpful? 0
  • +
  • -

#5 [email protected]   User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 174
  • Joined: 24-February 15

Re: RapidApi Instagram

Posted 07 July 2019 - 12:50 PM

Step by step I'm getting closer. My information get read out in the run section when I check it, but then in the end it says: at data of type org.json.JSONObject cannot be converted to JSONArray
Anyone what is going wrong

buttonParse.setonclickListener(new View.onclickListener() {
            @Override
            public void onclick(View v) {
                jsonParse();
            }
        });



private void jsonParse() {
        String url = "https://api.instagram.com/v1/users/self/?access_token=2086453534.15c5d2e.8a4c8d77992444459faf6e7f98005a4e\n";

        JsonObjectRequest request = new JsonObjectRequest(Request.Method.GET, url, null,
                new Response.Listener<JSONObject>() {
                    @Override
                    public void onResponse(JSONObject response) {
                        try {
                            JSONArray jsonArray = response.getJSONArray("data");

                            for (int i = 0; i < jsonArray.length(); i++) {
                                JSONObject data = jsonArray.getJSONObject(i);

                                String firstName = data.getString("id");
                                String username = data.getString("username");
                                String profile_picture = data.getString("profile_picture");

                                mTextViewResult.append(firstName + ", " + username + ", " + profile_picture + "\n\n");
                            }
                        } catch (JSONException e) {
                            e.printStackTrace();
                        }
                    }
                }, new Response.ErrorListener() {
            @Override
            public void onerrorResponse(VolleyError error) {
                error.printStackTrace();
            }
        });

        mQueue.add(request);
    }


Was This Post Helpful? 0
  • +
  • -

Page 1 of 1