adinan-cenci/scraping-instagram

This package is abandoned and no longer maintained. No replacement package was suggested.

Get instagram pictures, no api token needed.

1.0.4 2020-12-29 11:05 UTC

This package is auto-updated.

Last update: 2021-05-18 17:00:57 UTC


README

Instagram is going to such extent to protect their platform as to make scraping it a great endeavour and defeating the purpose of this library, meant to be of simple use.
I am sorry, but out there are projects better suited for it.

Instagram scraping

This is a PHP library to scrap pictures of profile pages on Instagram. No api token needed.

Why ?

Some people like to have their Instagram pictures displayed on their website, creating an app and generating a token is too much work for public available information, hence this library.

What ?

This library will not fetch one's entire gallery, only the few most recent pictures displayed on one's profile page. If you want to display more than 12 pictures at a time you may want to consider caching preview requests.

How ?

Just pass the user's handle to the constructor and call the ::fetch() method.

use AdinanCenci\ScrapingInstagram\Instagram;

$scraper  = new Instagram('noobmaster');

try {
    $pictures = $scraper->fetch();
} catch (\Exception $e) {
    echo 
    'Error: '.$e->getMessage();
    die();
}

It will return an array describing the pictures like so:

[
    {
        "caption": "Lorem ipsum dolor sit amet, consectetur ....",  
        "src": "https://instagram.ffln3....", 
        "thumbnails": {
            "150x150": "https://instagram.ffln....", 
            "240x240": "https://instagram.ffln....", 
            "320x320": "https://instagram.ffln....", 
            "480x480": "https://instagram.ffln....", 
            "640x640": "https://instagram.ffln...."
        }
    }, 
    {
        "caption": "Sed ut perspiciatis unde omnis iste ....", 
        "src": "https://instagram.ffln3....", 
        "thumbnails": {
            "150x150": "https://instagram.ffln....", 
            "240x240": "https://instagram.ffln....", 
            "320x320": "https://instagram.ffln....", 
            "480x480": "https://instagram.ffln....", 
            "640x640": "https://instagram.ffln...."
        }
    },
    {
        "caption": "At vero eos et accusamus et iusto odio ....", 
        "src": "https://instagram.ffln3....", 
        "thumbnails": {
            "150x150": "https://instagram.ffln....", 
            "240x240": "https://instagram.ffln....", 
            "320x320": "https://instagram.ffln....", 
            "480x480": "https://instagram.ffln....", 
            "640x640": "https://instagram.ffln...."
        }
    }
]

::unique()

A little method to remove duplicated pictures, helpful if you will be merging requests.

$newPictures = $scrapper->fetch();
$pictures    = array_merge($newPictures, $oldPictures);
$pictures    = Instagram::unique($pictures);

Installing

Use composer

composer require adinan-cenci/scraping-instagram

License

MIT