Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/postaddictme/instagram-php-scraper
Get account information, photos, videos, stories and comments.
https://github.com/postaddictme/instagram-php-scraper
instagram instagram-api instagram-client instagram-php-scraper instagram-scraper instagram-sdk
Last synced: 4 days ago
JSON representation
Get account information, photos, videos, stories and comments.
- Host: GitHub
- URL: https://github.com/postaddictme/instagram-php-scraper
- Owner: postaddictme
- License: mit
- Created: 2016-04-22T07:44:18.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2023-10-08T12:22:23.000Z (over 1 year ago)
- Last Synced: 2024-10-29T15:01:00.474Z (2 months ago)
- Topics: instagram, instagram-api, instagram-client, instagram-php-scraper, instagram-scraper, instagram-sdk
- Language: PHP
- Homepage: https://packagist.org/packages/raiym/instagram-php-scraper
- Size: 638 KB
- Stars: 3,093
- Watchers: 159
- Forks: 800
- Open Issues: 59
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
- stars - postaddictme/instagram-php-scraper - Get account information, photos, videos, stories and comments. (PHP)
README
# 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
- PHP >= 7.2
- [PSR-16](http://www.php-fig.org/psr/psr-16/)
- [PSR-18](http://www.php-fig.org/psr/psr-18/)## Code Example
```php
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:
```php
$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:
```php
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:
```php
// 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
```sh
composer.phar require raiym/instagram-php-scraper phpfastcache/phpfastcache
```
or
```sh
composer require raiym/instagram-php-scraper phpfastcache/phpfastcache
```### If you don't have composer
You can download it [here](https://getcomposer.org/download/).## Examples
See examples [here](https://github.com/postaddictme/instagram-php-scraper/tree/master/examples).## Other
Java library: https://github.com/postaddictme/instagram-java-scraper