Code Monkey home page Code Monkey logo

instagram-sdk's Introduction

Instagram-Sdk

Third party Instagram Sdk which provides a simple login button like facebook or twitter, and Handles the oauth2 flow for users to login and authenticate your app. The access token is stored in an Instagram session which persists upon closing the app.

Adding the Sdk to your project

Add the library as a dependency to your project. When using Android Studio and Gradle it's as easy as adding this dependency:

    compile 'com.mrunia.instagram.sdk:instagram.sdk:1.1.5'

Using the Sdk

Add the button to your xml layout file...

    <com.mrunia.instagram.sdk.InstagramLoginButton
      android:id="@+id/instagram_login_button"
      android:layout_width="wrap_content"
      android:layout_height="60dp"
      android:layout_gravity="center_horizontal"
      android:layout_marginTop="30dp"
    />

Add your ClientID, ClientSecret, and CallbackUrl Globals...

    String INSTA_CLIENT_ID = "your client id";
    String INSTA_CLIENT_SECRET = "your client secret";
    String INSTA_CALLBACK_URL = "your callback url - http://example.com";
    String[] INSTA_SCOPES = {"relationships", "likes", "comments"}; // or whatever your scopes are.
    InstagramAuthConfig instaAuthConfig = new InstagramAuthConfig(INSTA_CLIENT_ID, INSTA_CLIENT_SECRET, INSTA_CALLBACK_URL, INSTA_SCOPES);
    Instagram.getInstance().with(this, instaAuthConfig);

Grab the button from your layout and set the callback...

    instagramLogin = (InstagramLoginButton) findViewById(R.id.instagram_login_button);
    instagramLogin.setCallback(new com.mrunia.instagram.sdk.Callback<InstagramSession>() {
        @Override
        public void success(InstagramSession result) {
            // optional: put your own code here
            Log.i(TAG, "Instagram Logged in..."+result.toString());
        }

        @Override
        public void failure(Exception e) {
            // optional: put your own code here
            Log.i(TAG, "Instagram NOT Logged in...");
        }

        @Override
        public void logout() {
            // optional: put your own code here
            Log.i(TAG, "Instagram User was logged out...");
        }
    });

You can now use the Instagram AccessToken throughout your app to make Instagram Api calls...

    InstagramSession session = InstagramSession.getInstance(context);
    if(session.isSessionActive) {
        String accessToken = session.getAccessToken();
        String userName = session.getUsername();
        String userId = session.getId();
        ...
        
        // or get it all back using:
        HashMap sessionData = session.getSessionDetails();
        // then parse sessionData for your session data.
        
    }

ScreenShots

instagram-sdk's People

Watchers

 avatar  avatar

instagram-sdk's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.