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…

Dicembre 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
                    [text] => 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
                    [text] => 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
                    [text] => 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
                    [text] => 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
                    [text] => 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
                    [text] => 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
                    [text] => 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
                    [text] => 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
                    [text] => 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
                    [text] => 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
                    [text] => 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
                    [text] => #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
                    [text] => 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
                    [text] => 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
                    [text] => 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
                    [text] => 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
                    [text] => 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
                    [text] => 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
                    [text] => 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
                    [text] => 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

PHP expert. Wordpress plugin and theme developer. Father, Maker, Arduino and ESP8266 enthusiast.

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…

Agosto 18, 2011

Find values recursively inside complex json objects in PHP

A PHP function to to quickly search complex, nested php structures for specific values.

Dicembre 18, 2022

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…

Novembre 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…

Dicembre 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…

Novembre 12, 2013

How many times a web link has been shared on Twitter

Twitter share button and Facebook share button are the most used buttons to share links on Internet. You can read…

Ottobre 19, 2012