CodeIn House

  • Laravel
  • WordPress
  • jQuery
  • Javascript
  • Contact
Home   Laravel   Instagram Feed – Create Real-time Laravel Image Galler ...

Instagram Feed – Create Real-time Laravel Image Gallery Using Instagram Post API ?

March 9, 2019 by SNK

Instagram Feed - Create Real-time Laravel Image Gallery Using Instagram Post API ?

In this tutorial, we are going to see how to show Instagram feed on website using laravel. We are going to create real time image gallery using Instagram post api. This will help you fetch your most recent pictures and account information of the Instagram directly on the website.

If you own a profile or a travel agency website, it will help you get your Instagram feeds inside the website so, that you dont have to upload photos in two different place and also get the real time data via Instagram API.

First thing first, we need the Instagram API credentials so, head over to this article where i wrote how to generate Instagram API acess token and take a note of it. We will be needing it to fetch the real time data from your account. Next, we are going to use Instagram Package by Vinkala (Vincent Kaliber) which will help us to get the data from the Instagram using our API and access token.

We are also going to install some third party packages called php/http-message and php/guzzle6-adapter, which is required for Instagram package to make http calls to the Instagram API. We will look step by step process in order to achieve the result.

Let’s get started,

What are we going to do ?

  1. Fetching the necessary packages from GitHub repository.
  2. Adding access token inside laravel config file.
  3. Create new controller and configure routes.
  4. Finally fetch the data in your blade template.

Step 1 : Fetching the Necessary Packages from GitHub Repository

In this step we are going to pull some packages into our laravel application, go to terminal and then import these packages.

  1. Instagram package  – $ composer require vinkla/instagram
  2. php/http-message – $ composer require php-http/message
  3. php/guzzle6 adapter – $ composer require php-http/guzzle6-adapter

Or you can install all at once $ composer require vinkla/instagram php-http/message php-http/guzzle6-adapter

Once installed make sure that you php artisan dump-autoload, then after php artisan config:clear and cache:clear to remove all your caches are reload the config, because of the users are facing “ClassNotFoundException” issue while using this package.

Step 2 : Adding Access Token Inside Config File

The access token that you have generated from the third paragraph in this post, now, it is time to use it. We can use it inside the controller but lets make things cleaner and add this access token inside application root/app/config/services.php so that we could reuse it anywhere inside the application.

services.php
1
2
3
'instagram_api' => [
'token' => 'xxxxxxxxx.xxxxxx.xxxxxxxxxxxxxxx', // paste your access token inside quotes
],

We just have to type config(services.instagram_api.token) to access the token that we had just kept inside the services.php

Step 3 : Creating Controller and Configuring Routes.

In this step we are going to create new controller and configure routes to hit the api call.

Since, i am going to use Instagram API call, i’ll name it ApiController.php and use this controller for all the third party API calls.

Go ahead and make controller called ApiController.php and add this block of code inside it.

ApiController.php
PHP
1
2
3
4
5
6
7
8
9
10
public function getInstagramFeed() {
$instagram = new Instagram(config('services.instagram_api.token')); // new Instagram('xxxxx.xxx.xxxxxxxxxxxxxxx') access token can be directly used here.
 
$ig_images = [];
        foreach($instagram->get() as $insta_details) {
            $ig_images[] = $insta_details->images->standard_resolution->url;
        }
 
return view('index', ['ig_images'=>$ig_images]);
}

To make this implementation even more simple, we can make use of laravel collections,

Simplified Version
PHP
1
2
3
$ig_images = collect($instagram->get())->map(function ($item) {
return $item->images->standard_resolution->url;
});

Optional : 

To be more clear what inside the Instagram class object we can run dump server which is just added new to laravel 5.7, which will help us debug more clearly. Refer to our the new coming of laravel 5.7 to know more about it.

Open new terminal window and type php artisan dump.

Go back to code and inside getInstagram(); method comment all the codes below $instagram = new Instagram(config('services.instagram_api.token')); and dump($instagram->get());  and reload the application to see what we have fetched using the Instagram API. You will see all the details inside the dump server windows like below.

Larave Dump Server
PHP
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
Laravel Var Dump Server
=======================
 
 
[OK] Server listening on tcp://127.0.0.1:9912
 
 
// Quit the server with CONTROL-C.
 
 
GET http://localhost:8000/instagram-feed
----------------------------------------
 
------------ ----------------------------------------
  date         Wed, 12 Sep 2018 02:34:20 +0000
  controller   "ApiController"
  source       ApiController.php on line 12
  file         app\Http\Controllers\ApiController.php
------------ ----------------------------------------
 
array:8 [
  0 => {#235
    +"id": "1861782140564403504_8016644362"
    +"user": {#234
      +"id": "8016644362"
      +"full_name": "Travel To Nepal 😍🇳🇵"
      +"profile_picture": "https://scontent.cdninstagram.com/vp/36790f8e90fac1955fa112e312b00684/5C323C04/t51.2885-19/s150x150/39248393_290930611489538_4252559360149946368_n.jpg"
      +"username": "itravel2nepal"
    }
    +"images": {#236
      +"thumbnail": {#246
        +"width": 150
        +"height": 150
        +"url": "https://scontent.cdninstagram.com/vp/8e16916ecff17af735730d00d40b1db2/5C34A775/t51.2885-15/e35/c0.71.567.567/s150x150/40065590_532432193865209_1177565898102276096_n.jpg"
      }
      +"low_resolution": {#239
        +"width": 320
        +"height": 400
        +"url": "https://scontent.cdninstagram.com/vp/d0017bb9dee058f938d839495bb051a6/5C1E874E/t51.2885-15/e35/p320x320/40065590_532432193865209_1177565898102276096_n.jpg"
      }
      +"standard_resolution": {#238
        +"width": 640
        +"height": 800
        +"url": "https://scontent.cdninstagram.com/vp/609a4324247b06a3c05f46b4eba8814e/5C16F2EF/t51.2885-15/e35/40065590_532432193865209_1177565898102276096_n.jpg"
      }
    }
    +"created_time": "1536161747"
    +"caption": {#245
      +"id": "17917027330200584"
      +"text": "#nature #mountain #beautiful #cricket"
      +"created_time": "1536161747"
      +"from": {#232
        +"id": "8016644362"
        +"full_name": "Travel To Nepal 😍🇳🇵"
        +"profile_picture": "https://scontent.cdninstagram.com/vp/36790f8e90fac1955fa112e312b00684/5C323C04/t51.2885-19/s150x150/39248393_290930611489538_4252559360149946368_n.jpg"
        +"username": "itravel2nepal"
      }
    }
    +"user_has_liked": false
    +"likes": {#231
      +"count": 5
    }
    +"tags": array:4 [
      0 => "nature"
      1 => "beautiful"
      2 => "mountain"
      3 => "cricket"
    ]
    +"filter": "Clarendon"
    +"comments": {#244
      +"count": 0
    }
    +"type": "image"
    +"link": "https://www.instagram.com/p/BnWYP4hgfUw/"
    +"location": {#247
      +"latitude": 35.239166666667
      +"longitude": 74.59
      +"name": "Nanga Parbat"
      +"id": 354689810
    }
    +"attribution": null
    +"users_in_photo": []
  }
  1 => {#248
    +"id": "1858040490910540523_8016644362"
    +"user": {#249
      +"id": "8016644362"
      +"full_name": "Travel To Nepal 😍🇳🇵"
      +"profile_picture": "https://scontent.cdninstagram.com/vp/36790f8e90fac1955fa112e312b00684/5C323C04/t51.2885-19/s150x150/39248393_290930611489538_4252559360149946368_n.jpg"
      +"username": "itravel2nepal"
    }
    +"images": {#251
      +"thumbnail": {#250
        +"width": 150
        +"height": 150
        +"url": "https://scontent.cdninstagram.com/vp/64a5e7ac7126872b8e5dbe57ac6afcc2/5C372F3B/t51.2885-15/e35/c0.135.1080.1080/s150x150/39386880_240295889922408_1479121869851328512_n.jpg"
      }
      +"low_resolution": {#252
        +"width": 320
        +"height": 400
        +"url": "https://scontent.cdninstagram.com/vp/6226681ec2d92013b4668b43525071f6/5C1798C2/t51.2885-15/e35/p320x320/39386880_240295889922408_1479121869851328512_n.jpg"
      }
      +"standard_resolution": {#253
        +"width": 640
        +"height": 800
        +"url": "https://scontent.cdninstagram.com/vp/bf4005aeef7b2186fe50560a19c07b52/5C1F8095/t51.2885-15/sh0.08/e35/p640x640/39386880_240295889922408_1479121869851328512_n.jpg"
      }
    }
    +"created_time": "1535715708"
    +"caption": null
    +"user_has_liked": false
    +"likes": {#254
      +"count": 7
    }
    +"tags": []
    +"filter": "Clarendon"
    +"comments": {#255
      +"count": 0
    }
    +"type": "image"
    +"link": "https://www.instagram.com/p/BnJFftvA-Lr/"
    +"location": null
    +"attribution": null
    +"users_in_photo": []
  }
  2 => {#256
    +"id": "1857911338224005867_8016644362"
    +"user": {#257
      +"id": "8016644362"
      +"full_name": "Travel To Nepal 😍🇳🇵"
      +"profile_picture": "https://scontent.cdninstagram.com/vp/36790f8e90fac1955fa112e312b00684/5C323C04/t51.2885-19/s150x150/39248393_290930611489538_4252559360149946368_n.jpg"
      +"username": "itravel2nepal"
    }
    +"images": {#259
      +"thumbnail": {#258
        +"width": 150
        +"height": 150
        +"url": "https://scontent.cdninstagram.com/vp/f8eb1e53a07246b4d93f9079fae6a4d9/5C31BCD2/t51.2885-15/e35/c0.80.640.640/s150x150/40384337_1905193976205964_2314924429798277120_n.jpg"
      }
      +"low_resolution": {#260
        +"width": 320
        +"height": 400
        +"url": "https://scontent.cdninstagram.com/vp/9f168f5f7d034575234ed2cd33a39436/5C2CBB97/t51.2885-15/e35/p320x320/40384337_1905193976205964_2314924429798277120_n.jpg"
      }
      +"standard_resolution": {#261
        +"width": 640
        +"height": 800
        +"url": "https://scontent.cdninstagram.com/vp/f4f8b791053b525afb0207ec246da4e2/5C264300/t51.2885-15/e35/40384337_1905193976205964_2314924429798277120_n.jpg"
      }
    }
    +"created_time": "1535700312"
    +"caption": null
    +"user_has_liked": false
    +"likes": {#262
      +"count": 6
    }
    +"tags": []
    +"filter": "Clarendon"
    +"comments": {#263
      +"count": 0
    }
    +"type": "image"
    +"link": "https://www.instagram.com/p/BnIoIS7AzLr/"
    +"location": null
    +"attribution": null
    +"users_in_photo": []
  }
  3 => {#264
    +"id": "1857037779591222645_8016644362"
    +"user": {#265
      +"id": "8016644362"
      +"full_name": "Travel To Nepal 😍🇳🇵"
      +"profile_picture": "https://scontent.cdninstagram.com/vp/36790f8e90fac1955fa112e312b00684/5C323C04/t51.2885-19/s150x150/39248393_290930611489538_4252559360149946368_n.jpg"
      +"username": "itravel2nepal"
    }
    +"images": {#267
      +"thumbnail": {#266
        +"width": 150
        +"height": 150
        +"url": "https://scontent.cdninstagram.com/vp/59555fa4545bb6080e3bcfa0bf13feca/5C370C9D/t51.2885-15/e35/c0.92.1080.1080/s150x150/40083450_908788472653919_713225842586550272_n.jpg"
      }
      +"low_resolution": {#268
        +"width": 320
        +"height": 374
        +"url": "https://scontent.cdninstagram.com/vp/5ba63aa0392c5d7cd8a83c6d706ea3bf/5C2B8FD3/t51.2885-15/e35/p320x320/40083450_908788472653919_713225842586550272_n.jpg"
      }
      +"standard_resolution": {#269
        +"width": 640
        +"height": 749
        +"url": "https://scontent.cdninstagram.com/vp/4466db58820139f64558d69d39da78f1/5C23843F/t51.2885-15/sh0.08/e35/p640x640/40083450_908788472653919_713225842586550272_n.jpg"
      }
    }
    +"created_time": "1535596176"
    +"caption": {#270
      +"id": "17969181208067195"
      +"text": "#travelling #travel #tour #trek #nepal  #bajura #heaven"
      +"created_time": "1535596176"
      +"from": {#271
        +"id": "8016644362"
        +"full_name": "Travel To Nepal 😍🇳🇵"
        +"profile_picture": "https://scontent.cdninstagram.com/vp/36790f8e90fac1955fa112e312b00684/5C323C04/t51.2885-19/s150x150/39248393_290930611489538_4252559360149946368_n.jpg"
        +"username": "itravel2nepal"
      }
    }
    +"user_has_liked": false
    +"likes": {#272
      +"count": 13
    }
    +"tags": array:7 [
      0 => "bajura"
      1 => "travelling"
      2 => "nepal"
      3 => "tour"
      4 => "heaven"
      5 => "trek"
      6 => "travel"
    ]
    +"filter": "Clarendon"
    +"comments": {#273
      +"count": 0
    }
    +"type": "image"
    +"link": "https://www.instagram.com/p/BnFhgWDA9V1/"
    +"location": {#274
      +"latitude": 29.3833
      +"longitude": 81.3167
      +"name": "Bajura, Nepal"
      +"id": 297414239
    }
    +"attribution": null
    +"users_in_photo": []
  }
  4 => {#275
    +"id": "1857029186930193104_8016644362"
    +"user": {#276
      +"id": "8016644362"
      +"full_name": "Travel To Nepal 😍🇳🇵"
      +"profile_picture": "https://scontent.cdninstagram.com/vp/36790f8e90fac1955fa112e312b00684/5C323C04/t51.2885-19/s150x150/39248393_290930611489538_4252559360149946368_n.jpg"
      +"username": "itravel2nepal"
    }
    +"images": {#278
      +"thumbnail": {#277
        +"width": 150
        +"height": 150
        +"url": "https://scontent.cdninstagram.com/vp/1d6347f81876f9c6ead1732a77f490d0/5C2374F8/t51.2885-15/e35/c160.0.640.640/s150x150/39803335_1718979661562723_6146814738559926272_n.jpg"
      }
      +"low_resolution": {#279
        +"width": 320
        +"height": 213
        +"url": "https://scontent.cdninstagram.com/vp/2f3f820afda8075a471c9a5308e83bc2/5C17ADD4/t51.2885-15/e35/s320x320/39803335_1718979661562723_6146814738559926272_n.jpg"
      }
      +"standard_resolution": {#280
        +"width": 640
        +"height": 426
        +"url": "https://scontent.cdninstagram.com/vp/aab5375b80cae568e404951fd4207560/5C20D829/t51.2885-15/sh0.08/e35/s640x640/39803335_1718979661562723_6146814738559926272_n.jpg"
      }
    }
    +"created_time": "1535595151"
    +"caption": {#281
      +"id": "17975321602005406"
      +"text": "#travelling #travel #tour #trek #nepal  #bajura #heaven"
      +"created_time": "1535595151"
      +"from": {#282
        +"id": "8016644362"
        +"full_name": "Travel To Nepal 😍🇳🇵"
        +"profile_picture": "https://scontent.cdninstagram.com/vp/36790f8e90fac1955fa112e312b00684/5C323C04/t51.2885-19/s150x150/39248393_290930611489538_4252559360149946368_n.jpg"
        +"username": "itravel2nepal"
      }
    }
    +"user_has_liked": false
    +"likes": {#283
      +"count": 11
    }
    +"tags": array:7 [
      0 => "bajura"
      1 => "travelling"
      2 => "nepal"
      3 => "tour"
      4 => "heaven"
      5 => "trek"
      6 => "travel"
    ]
    +"filter": "Clarendon"
    +"comments": {#284
      +"count": 0
    }
    +"type": "image"
    +"link": "https://www.instagram.com/p/BnFfjTggbLQ/"
    +"location": {#285
      +"latitude": 29.3833
      +"longitude": 81.3167
      +"name": "Bajura, Nepal"
      +"id": 297414239
    }
    +"attribution": null
    +"users_in_photo": []
  }
  5 => {#286
    +"id": "1856340334733389825_8016644362"
    +"user": {#287
      +"id": "8016644362"
      +"full_name": "Travel To Nepal 😍🇳🇵"
      +"profile_picture": "https://scontent.cdninstagram.com/vp/36790f8e90fac1955fa112e312b00684/5C323C04/t51.2885-19/s150x150/39248393_290930611489538_4252559360149946368_n.jpg"
      +"username": "itravel2nepal"
    }
    +"images": {#289
      +"thumbnail": {#288
        +"width": 150
        +"height": 150
        +"url": "https://scontent.cdninstagram.com/vp/87d4f0b6c72f80f746358078c974e91e/5C32C6A2/t51.2885-15/e35/s150x150/39506611_504844986594043_2361962791364984832_n.jpg"
      }
      +"low_resolution": {#290
        +"width": 320
        +"height": 320
        +"url": "https://scontent.cdninstagram.com/vp/d086175abe2cb284e6dd6da8d34fdb20/5C305F52/t51.2885-15/e35/s320x320/39506611_504844986594043_2361962791364984832_n.jpg"
      }
      +"standard_resolution": {#291
        +"width": 640
        +"height": 640
        +"url": "https://scontent.cdninstagram.com/vp/b3f615dbc16d70d1b1a7a06fc1c3d4c9/5C37AE05/t51.2885-15/sh0.08/e35/s640x640/39506611_504844986594043_2361962791364984832_n.jpg"
      }
    }
    +"created_time": "1535513034"
    +"caption": null
    +"user_has_liked": false
    +"likes": {#292
      +"count": 14
    }
    +"tags": []
    +"filter": "Clarendon"
    +"comments": {#293
      +"count": 0
    }
    +"type": "image"
    +"link": "https://www.instagram.com/p/BnDC7L6A3AB/"
    +"location": {#294
      +"latitude": 27.861111111111
      +"longitude": 86.861388888889
      +"name": "Ama Dablam"
      +"id": 1.0816193254576E+14
    }
    +"attribution": null
    +"users_in_photo": []
  }
  6 => {#295
    +"id": "1855938598784754246_8016644362"
    +"user": {#296
      +"id": "8016644362"
      +"full_name": "Travel To Nepal 😍🇳🇵"
      +"profile_picture": "https://scontent.cdninstagram.com/vp/36790f8e90fac1955fa112e312b00684/5C323C04/t51.2885-19/s150x150/39248393_290930611489538_4252559360149946368_n.jpg"
      +"username": "itravel2nepal"
    }
    +"images": {#298
      +"thumbnail": {#297
        +"width": 150
        +"height": 150
        +"url": "https://scontent.cdninstagram.com/vp/8efbd83dd2119775c13d07908a0b99ce/5C1A35DB/t51.2885-15/e35/c14.0.691.691/s150x150/39921977_2030983106933466_3295970933881176064_n.jpg"
      }
      +"low_resolution": {#299
        +"width": 320
        +"height": 307
        +"url": "https://scontent.cdninstagram.com/vp/597c2338e015896df75a409e5172a2ec/5C364725/t51.2885-15/e35/s320x320/39921977_2030983106933466_3295970933881176064_n.jpg"
      }
      +"standard_resolution": {#300
        +"width": 640
        +"height": 615
        +"url": "https://scontent.cdninstagram.com/vp/e5ae00141bcf9cee3c16a382c540e4c4/5C3569D8/t51.2885-15/sh0.08/e35/s640x640/39921977_2030983106933466_3295970933881176064_n.jpg"
      }
    }
    +"created_time": "1535465143"
    +"caption": {#301
      +"id": "17900550895237649"
      +"text": "#Nepal #jumla"
      +"created_time": "1535465143"
      +"from": {#302
        +"id": "8016644362"
        +"full_name": "Travel To Nepal 😍🇳🇵"
        +"profile_picture": "https://scontent.cdninstagram.com/vp/36790f8e90fac1955fa112e312b00684/5C323C04/t51.2885-19/s150x150/39248393_290930611489538_4252559360149946368_n.jpg"
        +"username": "itravel2nepal"
      }
    }
    +"user_has_liked": false
    +"likes": {#303
      +"count": 9
    }
    +"tags": array:2 [
      0 => "nepal"
      1 => "jumla"
    ]
    +"filter": "Clarendon"
    +"comments": {#304
      +"count": 1
    }
    +"type": "image"
    +"link": "https://www.instagram.com/p/BnBnlKJgGJG/"
    +"location": {#305
      +"latitude": 23.42657
      +"longitude": 85.73424
      +"name": "Jumla"
      +"id": 6.6649785020756E+14
    }
    +"attribution": null
    +"users_in_photo": []
  }
  7 => {#306
    +"id": "1855937452112487383_8016644362"
    +"user": {#307
      +"id": "8016644362"
      +"full_name": "Travel To Nepal 😍🇳🇵"
      +"profile_picture": "https://scontent.cdninstagram.com/vp/36790f8e90fac1955fa112e312b00684/5C323C04/t51.2885-19/s150x150/39248393_290930611489538_4252559360149946368_n.jpg"
      +"username": "itravel2nepal"
    }
    +"images": {#309
      +"thumbnail": {#308
        +"width": 150
        +"height": 150
        +"url": "https://scontent.cdninstagram.com/vp/c36c242959e6b046796fb22edce3b4b7/5C2155AB/t51.2885-15/e35/c72.0.425.425/s150x150/39364469_321323645287227_7343053771485741056_n.jpg"
      }
      +"low_resolution": {#310
        +"width": 320
        +"height": 238
        +"url": "https://scontent.cdninstagram.com/vp/a36f3787c78b19872aaff5b4c4f1c7e9/5C26FD72/t51.2885-15/e35/s320x320/39364469_321323645287227_7343053771485741056_n.jpg"
      }
      +"standard_resolution": {#311
        +"width": 640
        +"height": 477
        +"url": "https://scontent.cdninstagram.com/vp/c9aa8c983148a32e5ed3de792708f098/5C3113C0/t51.2885-15/e35/39364469_321323645287227_7343053771485741056_n.jpg"
      }
    }
    +"created_time": "1535465006"
    +"caption": {#312
      +"id": "17953250023082578"
      +"text": "#travel #diaries #trek #nepal"
      +"created_time": "1535465006"
      +"from": {#313
        +"id": "8016644362"
        +"full_name": "Travel To Nepal 😍🇳🇵"
        +"profile_picture": "https://scontent.cdninstagram.com/vp/36790f8e90fac1955fa112e312b00684/5C323C04/t51.2885-19/s150x150/39248393_290930611489538_4252559360149946368_n.jpg"
        +"username": "itravel2nepal"
      }
    }
    +"user_has_liked": false
    +"likes": {#314
      +"count": 10
    }
    +"tags": array:4 [
      0 => "nepal"
      1 => "trek"
      2 => "travel"
      3 => "diaries"
    ]
    +"filter": "Clarendon"
    +"comments": {#315
      +"count": 2
    }
    +"type": "image"
    +"link": "https://www.instagram.com/p/BnBnUeOgiPX/"
    +"location": null
    +"attribution": null
    +"users_in_photo": []
  }
]

Now, configure the routes by going to routes/web.php.

web.php
PHP
1
Route::get("instagram-feed","ApiController@getInstagramFeed");

Step 4 : Fetching the Images Into the Blade Template

In this step we are going to display the images that have been pulled inside the ApiController.php into the blade template. Since my ApiController is pointing to my index page. I will just use normal foreach loop to loop over the image. Also, I have used bootstrap to make the dummy design quickly. Finally your code should look like this.

1
2
3
4
5
6
7
8
9
10
<div class="container">
    <h1 class="h1">Instagram Gallery</h1>
    <div class="row">
       @foreach($ig_images as $image)
           <div class="col-md-4" style="margin-bottom: 10px;">
               <img src="{{$image}}" alt="" style="width:100%; height:300px;" />
           </div>
           @endforeach
    </div>
</div>

After everything is complete, you should see your Instagram images in the index page. If you want, you can install jQuery Light box to make image zoom in a click and display as thumbnail and treat like an slide show.

This is it for this part of tutorial. If you went through any problem, make sure to mention them in comments.

SHARE ON
Buffer

Enjoyed this article?

Like us on

Laravel

Avatar for SNK

About SNK

Hello Welcome to my Blog. I develop Websites Using Laravel Framwork & WordPress. Get Latest updates on Facebook | Twitter

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Get Connected !! With Us

TOP POSTS

  • How to Setup Spring MVC Project From Scratch in Intellij IDEA ?
  • Spring Configuration Class in JAVA [Class VS XML Config]
  • Annotations Based Configuration in Spring Framework
  • How to Configure Spring Framework with XML Configurations?
  • How to Remove Project Name from URL in JSP Project in Intellij IDEA ?

TUTORIALS TILL DATE

  • September 2022 (6)
  • June 2021 (7)
  • October 2020 (5)
  • September 2020 (6)
  • September 2018 (14)
  • August 2018 (3)
  • July 2018 (4)
  • March 2018 (8)
  • February 2018 (5)
  • January 2018 (1)
  • December 2017 (2)
  • August 2017 (8)
  • May 2017 (1)
  • April 2017 (1)
  • March 2017 (4)
  • February 2017 (3)
  • January 2017 (4)

CATEGORIES

  • Angular (2)
  • CSS3 (3)
  • D3 (3)
  • HTML5 (7)
  • JAVA (11)
  • Javascript (20)
  • jQuery (8)
  • Laravel (35)
  • Others (3)
  • PHP (11)
  • Spring (2)
  • WordPress (10)

Top Categories

  • Angular
  • CSS3
  • D3
  • HTML5
  • JAVA
  • Javascript
  • jQuery
  • Laravel
  • Others
  • PHP
  • Spring
  • WordPress

Get in Touch

DMCA.com Protection Status

Recent Articles

  • How to Setup Spring MVC Project From Scratch in Intellij IDEA ?
  • Spring Configuration Class in JAVA [Class VS XML Config]
  • Annotations Based Configuration in Spring Framework
  • How to Configure Spring Framework with XML Configurations?
  • How to Remove Project Name from URL in JSP Project in Intellij IDEA ?

© 2012-22 CodeIn House.  •  All Rights Reserved.