2

i have created fb signup and twitter sign up with oriceon/oauth-laravel.I want instagram too.But iam stuck here.There is controller method for fb and twitter in the documentation provided here.I want a controller method for instagram too.Help me.

fighter
  • 149
  • 1
  • 8

1 Answers1

4

Like fb ,Twitter and google represented in the specified link,the Instagram can be applied like this.,

$code = $request->get('code');

        // get fb service
        $instagramService = \OAuth::consumer('Instagram');

        // check if code is valid

        // if code is provided get user data and sign in
        if ( ! is_null($code))
        {
            // retrieve the CSRF state parameter
            $state = isset($_GET['state']) ? $_GET['state'] : null;
            // This was a callback request from Instagram, get the token
            $instagramService->requestAccessToken($code, $state);
            // Send a request with it
            $result = json_decode($instagramService->request('users/self'), true);
            // Show some of the resultant data
            echo 'Your unique instagram user id is: ' . $result['data']['id'] . ' and your name is ' . $result['data']['full_name'];
        } else {
            $url = $instagramService->getAuthorizationUri();
            return redirect((string)$url);
        } 
Jasmel Pc
  • 515
  • 1
  • 5
  • 16