Skip to content

drfree1/instagram-php-scraper

This branch is 22 commits behind postaddictme/instagram-php-scraper:master.

Folders and files

NameName
Last commit message
Last commit date
Apr 16, 2019
Oct 18, 2021
Oct 18, 2021
Oct 22, 2020
Jan 18, 2021
Dec 12, 2016
May 14, 2019
Jun 4, 2019
Aug 14, 2021
Oct 22, 2020
Nov 25, 2018

Repository files navigation

Instagram PHP Scraper

This library is based on the Instagram web version. We develop it because nowadays it is hard to get an approved Instagram application. The purpose is to support every feature that the web desktop and mobile version support.

Dependencies

Code Example

use Phpfastcache\Helper\Psr16Adapter;

$instagram = \InstagramScraper\Instagram::withCredentials(new \GuzzleHttp\Client(), 'username', 'password', new Psr16Adapter('Files'));
$instagram->login();
$account = $instagram->getAccountById(3);
echo $account->getUsername();

Some methods do not require authentication:

$instagram = new \InstagramScraper\Instagram(new \GuzzleHttp\Client());
$nonPrivateAccountMedias = $instagram->getMedias('kevin');
echo $nonPrivateAccountMedias[0]->getLink();

If you use authentication it is recommended to cache the user session. In this case you don't need to run the $instagram->login() method every time your program runs:

use Phpfastcache\Helper\Psr16Adapter;

$instagram = \InstagramScraper\Instagram::withCredentials(new \GuzzleHttp\Client(), 'username', 'password', new Psr16Adapter('Files'));
$instagram->login(); // will use cached session if you want to force login $instagram->login(true)
$instagram->saveSession();  //DO NOT forget this in order to save the session, otherwise have no sense
$account = $instagram->getAccountById(3);
echo $account->getUsername();

Using proxy for requests:

// https://docs.guzzlephp.org/en/stable/request-options.html#proxy
$instagram = new \InstagramScraper\Instagram(new \GuzzleHttp\Client(['proxy' => 'tcp://localhost:8125']));
// Request with proxy
$account = $instagram->getAccount('kevin');
\InstagramScraper\Instagram::setHttpClient(new \GuzzleHttp\Client());
// Request without proxy
$account = $instagram->getAccount('kevin');

Installation

Using composer

composer.phar require raiym/instagram-php-scraper phpfastcache/phpfastcache

or

composer require raiym/instagram-php-scraper phpfastcache/phpfastcache

If you don't have composer

You can download it here.

Examples

See examples here.

Other

Java library: https://github.com/postaddictme/instagram-java-scraper

About

Get account information, photos, videos, stories and comments.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%