Get instagram data without official api in PHP

Instagram has an official API to interact with its database of images and users. If you have enough time to…

December 3, 2013

Instagram has an official API to interact with its database of images and users. If you have enough time to understand oAuth protocol and build a bunch of functions to deal with instagram API, that’s the best way… But if you need just a minimal integration and you need to go fast, probably it’s enough the getInstagramPics method of the Minibots class.
With this method you can retrieve the last pictures of a public instagram profile and also some data linked to the profile, such as the avatar, the number of files and more.
Here is the data you can retrieve with Minibots class and how to:

Example: Get Instagram data without api

Just include the class, get an instance and call the getInstagramPics method:

<?
include ("minibots.class.php");
$mb = new Minibots();
$data = $mb->getInstagramPics("giuliopons");
print_r($data);
?>

Data ouput for getInstagram method:

As you can see the output is made of two elements of an array: the first is $data['user'], which contains a standard class object with the data of the user, so, if yuo want to retrieve the full name you have to use $data['user']->full_name. To retrieve the number of followers you have to use $data['user']->counts->followed_by and so on…
The second is $data['pics'] which contains an array of the last 20 pictures uploaded by the user.
To print them you can use a code like this:

foreach($data["pics"] as $img) {
	echo "<img src=\"".$img["thumbnail"]."\" width='150'/>";
}

Here is the full data ouput:

Array
(
    [user] => stdClass Object
        (
            [username] => giuliopons
            [bio] => E' importante inseguire la felicità .
            [website] => http://www.rockit.it
            [profile_picture] => http://images.ak.instagram.com/profiles/profile_1279802_75sq_1318453811.jpg
            [full_name] => Giulio Pons
            [counts] => stdClass Object
                (
                    [media] => 1197
                    [followed_by] => 655
                    [follows] => 121
                )

            [id] => 1279802
        )

    [pics] => Array
        (
            [0] => Array
                (
                    [link] => http://instagram.com/p/hb_xxVSw0c/
                    [likes] => 1
                    [created] => 1386026398
                     => Apparecchiata!
                    [low_resolution] => http://distilleryimage4.s3.amazonaws.com/3d8a199a5ba811e3b4cb0a0d88bf3520_6.jpg
                    [standard_resolution] => http://distilleryimage4.s3.amazonaws.com/3d8a199a5ba811e3b4cb0a0d88bf3520_8.jpg
                    [thumbnail] => http://distilleryimage4.s3.amazonaws.com/3d8a199a5ba811e3b4cb0a0d88bf3520_5.jpg
                )

            [1] => Array
                (
                    [link] => http://instagram.com/p/hGfiSaSwzl/
                    [likes] => 7
                    [created] => 1385304862
                     => Che facce!!
                    [low_resolution] => http://distilleryimage5.s3.amazonaws.com/41f084d8551811e38d2b12bbbb3e8362_6.jpg
                    [standard_resolution] => http://distilleryimage5.s3.amazonaws.com/41f084d8551811e38d2b12bbbb3e8362_8.jpg
                    [thumbnail] => http://distilleryimage5.s3.amazonaws.com/41f084d8551811e38d2b12bbbb3e8362_5.jpg
                )

            [2] => Array
                (
                    [link] => http://instagram.com/p/giXgHnSw-P/
                    [likes] => 7
                    [created] => 1384092704
                     => Barbie col burka e Barbie gonze.
                    [low_resolution] => http://distilleryimage7.s3.amazonaws.com/f35904c84a1111e3b0ef12eff38310dc_6.jpg
                    [standard_resolution] => http://distilleryimage7.s3.amazonaws.com/f35904c84a1111e3b0ef12eff38310dc_8.jpg
                    [thumbnail] => http://distilleryimage7.s3.amazonaws.com/f35904c84a1111e3b0ef12eff38310dc_5.jpg
                )

            [3] => Array
                (
                    [link] => http://instagram.com/p/giI1S0Sw7L/
                    [likes] => 10
                    [created] => 1384084992
                     => Melograno gigante!!
                    [low_resolution] => http://distilleryimage3.s3.amazonaws.com/0b3db0824a0011e38e4d0a7011810191_6.jpg
                    [standard_resolution] => http://distilleryimage3.s3.amazonaws.com/0b3db0824a0011e38e4d0a7011810191_8.jpg
                    [thumbnail] => http://distilleryimage3.s3.amazonaws.com/0b3db0824a0011e38e4d0a7011810191_5.jpg
                )

            [4] => Array
                (
                    [link] => http://instagram.com/p/giFjFSSw4O/
                    [likes] => 12
                    [created] => 1384083302
                     => Mio papà inviato al Quirinale da Napolitano. O___O
                    [low_resolution] => http://distilleryimage10.s3.amazonaws.com/08d1082a49fc11e395eb126dff410949_6.jpg
                    [standard_resolution] => http://distilleryimage10.s3.amazonaws.com/08d1082a49fc11e395eb126dff410949_8.jpg
                    [thumbnail] => http://distilleryimage10.s3.amazonaws.com/08d1082a49fc11e395eb126dff410949_5.jpg
                )

            [5] => Array
                (
                    [link] => http://instagram.com/p/gP_NfDSw3Z/
                    [likes] => 8
                    [created] => 1383475974
                     => La cumpa.
                    [low_resolution] => http://distilleryimage9.s3.amazonaws.com/0c5cbff6447611e3999722000a1fcf03_6.jpg
                    [standard_resolution] => http://distilleryimage9.s3.amazonaws.com/0c5cbff6447611e3999722000a1fcf03_7.jpg
                    [thumbnail] => http://distilleryimage9.s3.amazonaws.com/0c5cbff6447611e3999722000a1fcf03_5.jpg
                )

            [6] => Array
                (
                    [link] => http://instagram.com/p/gP-4NlSw2-/
                    [likes] => 5
                    [created] => 1383475785
                     => Una crepa nel continuum spazio temporale mi ha riportato a giugno.
                    [low_resolution] => http://distilleryimage10.s3.amazonaws.com/a47d43e2447511e3a99f22000ab5bc02_6.jpg
                    [standard_resolution] => http://distilleryimage10.s3.amazonaws.com/a47d43e2447511e3a99f22000ab5bc02_7.jpg
                    [thumbnail] => http://distilleryimage10.s3.amazonaws.com/a47d43e2447511e3a99f22000ab5bc02_5.jpg
                )

            [7] => Array
                (
                    [link] => http://instagram.com/p/gOEHZcyw9V/
                    [likes] => 8
                    [created] => 1383411447
                     => Ho fatto amicizia col leone.
                    [low_resolution] => http://distilleryimage5.s3.amazonaws.com/c920a0d643df11e391a022000a9f13ef_6.jpg
                    [standard_resolution] => http://distilleryimage5.s3.amazonaws.com/c920a0d643df11e391a022000a9f13ef_7.jpg
                    [thumbnail] => http://distilleryimage5.s3.amazonaws.com/c920a0d643df11e391a022000a9f13ef_5.jpg
                )

            [8] => Array
                (
                    [link] => http://instagram.com/p/gODVfASw8E/
                    [likes] => 4
                    [created] => 1383411051
                     => Compiti.
                    [low_resolution] => http://distilleryimage0.s3.amazonaws.com/d56aa08643de11e3902222000a1fa52b_6.jpg
                    [standard_resolution] => http://distilleryimage0.s3.amazonaws.com/d56aa08643de11e3902222000a1fa52b_7.jpg
                    [thumbnail] => http://distilleryimage0.s3.amazonaws.com/d56aa08643de11e3902222000a1fa52b_5.jpg
                )

            [9] => Array
                (
                    [link] => http://instagram.com/p/gNPa4OSw0x/
                    [likes] => 17
                    [created] => 1383383799
                     => Oggi si pesca duro.
                    [low_resolution] => http://distilleryimage5.s3.amazonaws.com/75c2834a439f11e3af3822000ae802ec_6.jpg
                    [standard_resolution] => http://distilleryimage5.s3.amazonaws.com/75c2834a439f11e3af3822000ae802ec_7.jpg
                    [thumbnail] => http://distilleryimage5.s3.amazonaws.com/75c2834a439f11e3af3822000ae802ec_5.jpg
                )

            [10] => Array
                (
                    [link] => http://instagram.com/p/gLTqRFSw9S/
                    [likes] => 13
                    [created] => 1383318922
                     => Dolcetto o scherzetto?
                    [low_resolution] => http://distilleryimage10.s3.amazonaws.com/62e5eeb6430811e3a49a22000aeb0bdf_6.jpg
                    [standard_resolution] => http://distilleryimage10.s3.amazonaws.com/62e5eeb6430811e3a49a22000aeb0bdf_7.jpg
                    [thumbnail] => http://distilleryimage10.s3.amazonaws.com/62e5eeb6430811e3a49a22000aeb0bdf_5.jpg
                )

            [11] => Array
                (
                    [link] => http://instagram.com/p/gLJTTxyw_o/
                    [likes] => 7
                    [created] => 1383313478
                     => #relax
                    [low_resolution] => http://distilleryimage4.s3.amazonaws.com/bdcc067442fb11e3a5a022000ae9129a_6.jpg
                    [standard_resolution] => http://distilleryimage4.s3.amazonaws.com/bdcc067442fb11e3a5a022000ae9129a_7.jpg
                    [thumbnail] => http://distilleryimage4.s3.amazonaws.com/bdcc067442fb11e3a5a022000ae9129a_5.jpg
                )

            [12] => Array
                (
                    [link] => http://instagram.com/p/gLIHrjSw-N/
                    [likes] => 6
                    [created] => 1383312898
                     => Evviva!
                    [low_resolution] => http://distilleryimage1.s3.amazonaws.com/4c84536e42fa11e3afd722000a1f98d6_6.jpg
                    [standard_resolution] => http://distilleryimage1.s3.amazonaws.com/4c84536e42fa11e3afd722000a1f98d6_7.jpg
                    [thumbnail] => http://distilleryimage1.s3.amazonaws.com/4c84536e42fa11e3afd722000a1f98d6_5.jpg
                )

            [13] => Array
                (
                    [link] => http://instagram.com/p/gLB9dHSw1N/
                    [likes] => 9
                    [created] => 1383309654
                     => Susanna è finita diretta stessa in acqua. :) meno male che c'è il sole.
                    [low_resolution] => http://distilleryimage9.s3.amazonaws.com/c795c01842f211e393e422000a1fbe78_6.jpg
                    [standard_resolution] => http://distilleryimage9.s3.amazonaws.com/c795c01842f211e393e422000a1fbe78_7.jpg
                    [thumbnail] => http://distilleryimage9.s3.amazonaws.com/c795c01842f211e393e422000a1fbe78_5.jpg
                )

            [14] => Array
                (
                    [link] => http://instagram.com/p/gLA2_hywzp/
                    [likes] => 5
                    [created] => 1383309090
                     => Mare! Arrivo!
                    [low_resolution] => http://distilleryimage5.s3.amazonaws.com/6f87bd4642f111e3803822000ae90265_6.jpg
                    [standard_resolution] => http://distilleryimage5.s3.amazonaws.com/6f87bd4642f111e3803822000ae90265_7.jpg
                    [thumbnail] => http://distilleryimage5.s3.amazonaws.com/6f87bd4642f111e3803822000ae90265_5.jpg
                )

            [15] => Array
                (
                    [link] => http://instagram.com/p/gJOlPbSw6Z/
                    [likes] => 11
                    [created] => 1383249155
                     => Girati che ti faccio una foto! No! Beccata! Uffa!
                    [low_resolution] => http://distilleryimage1.s3.amazonaws.com/efd99456426511e3842f22000aeb3ed0_6.jpg
                    [standard_resolution] => http://distilleryimage1.s3.amazonaws.com/efd99456426511e3842f22000aeb3ed0_7.jpg
                    [thumbnail] => http://distilleryimage1.s3.amazonaws.com/efd99456426511e3842f22000aeb3ed0_5.jpg
                )

            [16] => Array
                (
                    [link] => http://instagram.com/p/f-jAlDywzw/
                    [likes] => 8
                    [created] => 1382891771
                     => Ciao!
                    [low_resolution] => http://distilleryimage8.s3.amazonaws.com/7f57a69a3f2311e39b6f22000ae91215_6.jpg
                    [standard_resolution] => http://distilleryimage8.s3.amazonaws.com/7f57a69a3f2311e39b6f22000ae91215_7.jpg
                    [thumbnail] => http://distilleryimage8.s3.amazonaws.com/7f57a69a3f2311e39b6f22000ae91215_5.jpg
                )

            [17] => Array
                (
                    [link] => http://instagram.com/p/f-bg8-yw1F/
                    [likes] => 10
                    [created] => 1382886841
                     => Tre teppe.
                    [low_resolution] => http://distilleryimage1.s3.amazonaws.com/596aa0123f1a11e3839022000ab5bd98_6.jpg
                    [standard_resolution] => http://distilleryimage1.s3.amazonaws.com/596aa0123f1a11e3839022000ab5bd98_7.jpg
                    [thumbnail] => http://distilleryimage1.s3.amazonaws.com/596aa0123f1a11e3839022000ab5bd98_5.jpg
                )

            [18] => Array
                (
                    [link] => http://instagram.com/p/f3C-_kSwxj/
                    [likes] => 17
                    [created] => 1382639103
                     => Orgogliosissimo del ritratto che mi ha fatto la Ceci. :-)
                    [low_resolution] => http://distilleryimage3.s3.amazonaws.com/8798bb383cd911e3bacd22000a9e08df_6.jpg
                    [standard_resolution] => http://distilleryimage3.s3.amazonaws.com/8798bb383cd911e3bacd22000a9e08df_7.jpg
                    [thumbnail] => http://distilleryimage3.s3.amazonaws.com/8798bb383cd911e3bacd22000a9e08df_5.jpg
                )

            [19] => Array
                (
                    [link] => http://instagram.com/p/fp-AQLSwwh/
                    [likes] => 5
                    [created] => 1382200256
                     => Area video sorvegliata senza niente.
                    [low_resolution] => http://distilleryimage5.s3.amazonaws.com/d340aa8e38db11e39b6c22000ab5c529_6.jpg
                    [standard_resolution] => http://distilleryimage5.s3.amazonaws.com/d340aa8e38db11e39b6c22000ab5c529_7.jpg
                    [thumbnail] => http://distilleryimage5.s3.amazonaws.com/d340aa8e38db11e39b6c22000ab5c529_5.jpg
                )

        )

)

You can see an application made to send Instragram images as postcards via email, made using this class here, it’s: Instapostcards.

All this data are parsed by the getInstagramPics method from the Instagram official public web site. Parsing is made inside the Minibots PHP Class.

Author

I'm a software engineer, an everyday web developer and a maker. I usually build sites with PHP, within or without WordPress. I build Internet of Things with Arduino and ESP8266. I'm the founder of Rockit.it and Dailybest.it and I'm actually the Chief Technical Officer of Better Days web agency.

Recommended

How to use Instagr.am photos on your site

UPDATE: 2013-12-04 I’ve made a method in the Mini Bots PHP Class that lets you retrieve images from instagram without…

August 18, 2011

Twitter counter no longer works

Since 20 of November 2015 the twitter button has changed. This is the new Twitter sharing button, as you can…

November 23, 2015

Scraping content with PHP as if it was jQuery

Building a spider or a bot needs some knowledge of regular expressions, you must know and use preg_match or preg_match_all…

December 8, 2013

Make a cron job with IFTTT

Cron is a software utility, a time-based job scheduler in Unix-like computer operating systems. People who set up and maintain…

November 12, 2013

How to read facebook likes count from PHP

When you add facebook like button to your site, probably, you also want to save the number of likes of…

October 8, 2012

PHP code to check if remote mp3 exists

Hi, I’ve a big table with thousands of mp3 links. Sice these links come from an old database, many of…

November 1, 2011