'i want to get Instagram profile total followers and following and post get this error 429 Too Many Requests on laravel

I want to get Instagram profile total followers and following and post get this error" 429 Too Many Requests on Laravel.

enter image description here

I need for it to show my users profile information on their account page on my website. I tried it, but I didn't get the profile json data.

Here I send my route view and controller.

1. routes/web.php

Route::get('instagram', 'InstagramController@index');

2. app/Http/Controllers/InstagramController.php

<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Requests;
class InstagramController extends Controller {
    /**
     * Get the index name for the model.
     *
     * @return string
    */
    public function index(Request $request) {
        $items = [];
        if($request->has('username')){
     $client = new \GuzzleHttp\Client;
     $url = sprintf('https://www.instagram.com/%s/media', $request->input('username'));
         $response = $client->get($url);
         $items = json_decode((string) $response->getBody(), true)['items'];
        }
        return view('instagram',compact('items'));
    }
}

3. resources/views/instagram.blade.php

<!DOCTYPE html>
<html>
    <head>
        <title>Laravel 5 Instagram API tutorial with example</title>
        <link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
    </head>
    <body>

    <div class="container">
        <h2>Laravel 5 Instagram API tutorial with example</h2><br/>
        <form method="GET" role="form">
            <div class="row">
                <div class="col-md-6">
                    <div class="form-group">
                        <input type="text" id="username" name="username" class="form-control" placeholder="Enter Instagram Username" value="{{ old('username') }}">
                    </div>
                </div>
                <div class="col-md-6">
                    <div class="form-group">
                        <button class="btn btn-success">Search</button>
                    </div>
                </div>
            </div>
        </form>

        <div class="panel panel-primary">
          <div class="panel-heading">Instagram Feed</div>
          <div class="panel-body">
                <table class="table table-bordered">
                    <thead>
                        <th>No</th>
                        <th width="200px;">Id</th>
                        <th>Code</th>
                        <th>Image</th>
                        <th>Location</th>
                        <th>Total Likes</th>
                        <th>Total Comments</th>
                    </thead>
                    <tbody>
                        @if(!empty($items))
                         @foreach($items as $key => $item)
                           <tr>
                            <td>{{ ++$key }}</td>
                            <td>{{ $item['id'] }}</td>
                            <td>{{ $item['code'] }}</td>
                            <td><img src="{{ $item['images']['standard_resolution']['url'] }}" style="width:100px;"></td>
                            <td>{{ isset($item['location']['name']) ? $item['location']['name'] : '' }}</td>
                            <td>{{ $item['likes']['count'] }}</td>
                            <td>{{ $item['comments']['count'] }}</td>
                           </tr>
                          @endforeach
                        @else
                           <tr>
                            <td colspan="4">There are no data.</td>
                           </tr>
                        @endif
                    </tbody>
                </table>
            </div>
        </div>
    </div>
    </body>
</html>


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source