Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: postaddictme/instagram-php-scraper
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v0.8.1
Choose a base ref
...
head repository: postaddictme/instagram-php-scraper
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref

Commits on Mar 7, 2017

  1. Merge pull request #1 from postaddictme/master

    Update
    Mulkave authored Mar 7, 2017
    Copy the full SHA
    fec6ecd View commit details

Commits on Nov 8, 2017

  1. Merge pull request #2 from postaddictme/master

    Updating fork
    Mulkave authored Nov 8, 2017
    Copy the full SHA
    13fa13a View commit details
  2. 1
    Copy the full SHA
    561f381 View commit details
  3. #197

    raiym committed Nov 8, 2017
    Copy the full SHA
    c1c01ed View commit details
  4. Copy the full SHA
    39f5f94 View commit details
  5. Fixes #200. Likes count bug

    raiym committed Nov 8, 2017
    Copy the full SHA
    b87f7df View commit details

Commits on Nov 9, 2017

  1. getPaginateMedias() fix

    ezobraz committed Nov 9, 2017
    Copy the full SHA
    6384e74 View commit details
  2. Merge pull request #204 from ezobraz/master

    getPaginateMedias() fix
    raiym authored Nov 9, 2017
    Copy the full SHA
    e819fe2 View commit details

Commits on Nov 10, 2017

  1. Copy the full SHA
    2b13036 View commit details
  2. Merge pull request #209 from jasonadkison/bugfix/media-caption

    safe access media caption array element
    raiym authored Nov 10, 2017
    Copy the full SHA
    980b1ce View commit details

Commits on Nov 17, 2017

  1. Fix #20 Get Media Likes

    eversionsystems authored Nov 17, 2017
    Copy the full SHA
    88f5c2d View commit details
  2. Fix #20 Get Media Likes

    eversionsystems authored Nov 17, 2017
    Copy the full SHA
    6060bf9 View commit details

Commits on Nov 18, 2017

  1. Fix #20 Get Media Likes

    Modified the likes max id.
    eversionsystems authored Nov 18, 2017
    Copy the full SHA
    5c813db View commit details

Commits on Nov 19, 2017

  1. Merge pull request #216 from eversionsystems/master

    Fix #20 Get Media Likes
    raiym authored Nov 19, 2017
    Copy the full SHA
    b84a101 View commit details

Commits on Nov 21, 2017

  1. Copy the full SHA
    425790a View commit details

Commits on Nov 23, 2017

  1. Copy the full SHA
    4da8efe View commit details
  2. Merge pull request #223 from s3ri0usman/master

    Fixed returning user id for not 64 bit php systems
    raiym authored Nov 23, 2017
    Copy the full SHA
    e7b08cf View commit details
  3. Copy the full SHA
    09d6cb5 View commit details
  4. Merge pull request #222 from shibby/patch-1

    Fix PHP Notice on ArrayLikeTrait
    raiym authored Nov 23, 2017
    Copy the full SHA
    cd89cbc View commit details

Commits on Nov 25, 2017

  1. Can get list of accounts a user is following

    Rachmatullah, Agro committed Nov 25, 2017
    Copy the full SHA
    5be4c30 View commit details
  2. Bug fix

    Rachmatullah, Agro committed Nov 25, 2017
    Copy the full SHA
    3172fa8 View commit details
  3. Merge pull request #224 from agro1986/feature/20171125_get_following

    Feature/20171125 get following
    raiym authored Nov 25, 2017
    Copy the full SHA
    e1ae14c View commit details

Commits on Nov 26, 2017

  1. customizable timing for paging operations

    Rachmatullah, Agro committed Nov 26, 2017
    Copy the full SHA
    3e20423 View commit details

Commits on Dec 4, 2017

  1. Parse instagram stories

    Anton Rusakov committed Dec 4, 2017
    Copy the full SHA
    e77314c View commit details

Commits on Dec 5, 2017

  1. Merge pull request #226 from agro1986/feature/20171126_customizable_t…

    …iming
    
    customizable timing for paging operations
    raiym authored Dec 5, 2017
    Copy the full SHA
    998e5d9 View commit details
  2. Merge pull request #231 from rusan/master

    Parse instagram stories
    raiym authored Dec 5, 2017
    Copy the full SHA
    f4295ef View commit details

Commits on Dec 7, 2017

  1. Copy the full SHA
    4c14ffc View commit details

Commits on Dec 8, 2017

  1. Merge pull request #233 from s3ri0usman/master

    Added ability to use proxy for requests
    raiym authored Dec 8, 2017
    1
    Copy the full SHA
    d02de7e View commit details

Commits on Dec 11, 2017

  1. Update Media.php

    Fix locationId for posts where location is provided; See #232
    tomassrnka authored Dec 11, 2017
    Copy the full SHA
    d6ee38a View commit details
  2. Save query ids in special file

    Anton Rusakov committed Dec 11, 2017
    Copy the full SHA
    041079c View commit details

Commits on Dec 12, 2017

  1. Merge pull request #235 from tomassrnka/patch-1

    Update Media.php
    raiym authored Dec 12, 2017
    Copy the full SHA
    3574393 View commit details
  2. Merge pull request #236 from rusan/master

    Save query ids in special file
    raiym authored Dec 12, 2017
    Copy the full SHA
    6e22178 View commit details
  3. Copy the full SHA
    a52b462 View commit details
  4. Right usage of reel_ids paramtr

    Anton Rusakov committed Dec 12, 2017
    Copy the full SHA
    7765e03 View commit details
  5. Extend description for parametr

    Anton Rusakov committed Dec 12, 2017
    Copy the full SHA
    06dae87 View commit details
  6. Right names for models

    Anton Rusakov committed Dec 12, 2017
    Copy the full SHA
    8fe6d6c View commit details
  7. Support two step verification in cli mode

    Anton Rusakov committed Dec 12, 2017
    Copy the full SHA
    8abf8f6 View commit details
  8. Rollback private for parse cookie function

    Anton Rusakov committed Dec 12, 2017
    Copy the full SHA
    8c79480 View commit details

Commits on Dec 13, 2017

  1. Fix for other type of answer for choose method

    Anton Rusakov committed Dec 13, 2017
    Copy the full SHA
    5e257ff View commit details

Commits on Dec 14, 2017

  1. Merge pull request #239 from rusan/master

     Get reel_ids as paramtr. If it empty - it will make a query for get it.
    raiym authored Dec 14, 2017
    Copy the full SHA
    d94449c View commit details
  2. Merge pull request #240 from rusan/right_model_names

    Right names for models
    raiym authored Dec 14, 2017
    Copy the full SHA
    8892265 View commit details
  3. Merge pull request #241 from rusan/two_step_verification_support

    Two step verification support
    raiym authored Dec 14, 2017
    Copy the full SHA
    3c46194 View commit details

Commits on Dec 22, 2017

  1. Update Location.php

    Add 'modified' field and corresponding functions for Location model.
    tomassrnka authored Dec 22, 2017
    Copy the full SHA
    297b4f5 View commit details

Commits on Dec 23, 2017

  1. Merge pull request #247 from tomassrnka/patch-2

    Update Location.php
    raiym authored Dec 23, 2017
    Copy the full SHA
    3ba9912 View commit details

Commits on Dec 24, 2017

  1. Square thumbnails URL

    rhcarlosweb committed Dec 24, 2017
    Copy the full SHA
    5edd873 View commit details

Commits on Dec 26, 2017

  1. Update getAccountById Example

    Fixed item:
    follows and followers Titles and values was displaced and fixed now
    rezvani authored Dec 26, 2017
    Copy the full SHA
    483a84b View commit details

Commits on Jan 4, 2018

  1. Copy the full SHA
    f9f3212 View commit details

Commits on Jan 9, 2018

  1. Update getPaginateMediasByTag

    esmazguhin committed Jan 9, 2018
    Copy the full SHA
    4a43cab View commit details
  2. Merge pull request #248 from rhcarlosweb/develop

    Square thumbnails URL
    raiym authored Jan 9, 2018
    Copy the full SHA
    3ed2014 View commit details
  3. Merge pull request #249 from rezvani/patch-1

    Update getAccountById Example
    raiym authored Jan 9, 2018
    Copy the full SHA
    2b741dc View commit details
Showing with 6,612 additions and 863 deletions.
  1. +17 −0 .github/stale.yml
  2. +3 −1 .gitignore
  3. +1 −0 CONTRIBUTING.md
  4. +21 −0 LICENSE
  5. +36 −12 README.md
  6. +16 −6 composer.json
  7. +20 −0 examples/addAndDeleteComment.php
  8. +17 −0 examples/followAndUnfollow.php
  9. +4 −6 examples/getAccountById.php
  10. +1 −1 examples/getAccountByUsername.php
  11. +4 −2 examples/getAccountFollowers.php
  12. +15 −0 examples/getAccountFollowings.php
  13. +5 −3 examples/getAccountMediasByUsername.php
  14. +22 −12 examples/getCurrentTopMediasByLocationId.php
  15. +4 −2 examples/getCurrentTopMediasByTagName.php
  16. +15 −0 examples/getFeed.php
  17. +63 −0 examples/getHighlights.php
  18. +26 −0 examples/getInbox.php
  19. +3 −1 examples/getLocationById.php
  20. +9 −4 examples/getMediaByCode.php
  21. +7 −5 examples/getMediaById.php
  22. +7 −5 examples/getMediaByUrl.php
  23. +3 −1 examples/getMediaComments.php
  24. +21 −12 examples/getMediasByLocationId.php
  25. +4 −2 examples/getMediasByTag.php
  26. +96 −0 examples/getPaginateFeed.php
  27. +52 −0 examples/getPaginateMediaComments.php
  28. +4 −2 examples/getPaginateMediasByTag.php
  29. +31 −0 examples/getPaginateMediasByUsername.php
  30. +41 −0 examples/getSidecarMediaByUrl.php
  31. +15 −0 examples/getStories.php
  32. +61 −0 examples/getStoriesFromUserStories.php
  33. +47 −0 examples/getThreads.php
  34. +26 −0 examples/getUserStoryByUrl.php
  35. +27 −0 examples/getUserTags.php
  36. +45 −0 examples/likeAndUnlikeMedia.php
  37. +14 −0 examples/loginWithSessionId.php
  38. +4 −4 examples/paginateAccountMediaByUsername.php
  39. +39 −0 examples/removeFollower.php
  40. +44 −0 examples/saveSessionWithLongExpirationDate.php
  41. +3 −1 examples/searchAccountsByUsername.php
  42. +15 −0 examples/searchUsersByFollowers.php
  43. +30 −0 examples/setCustomCookies.php
  44. +139 −0 examples/twoStepAutoVerification/EmailVerification.php
  45. +20 −0 examples/twoStepAutoVerification/loginWithEmailAutoCponfirm.php
  46. +11 −0 phpunit.xml.dist
  47. +5 −4 src/InstagramScraper.php
  48. +205 −23 src/InstagramScraper/Endpoints.php
  49. +11 −0 src/InstagramScraper/Exception/InstagramAgeRestrictedException.php
  50. +5 −3 src/InstagramScraper/Exception/InstagramAuthException.php
  51. +11 −0 src/InstagramScraper/Exception/InstagramChallengeRecaptchaException.php
  52. +11 −0 src/InstagramScraper/Exception/InstagramChallengeSubmitPhoneNumberException.php
  53. +17 −0 src/InstagramScraper/Exception/InstagramException.php
  54. +5 −1 src/InstagramScraper/Exception/InstagramNotFoundException.php
  55. +81 −0 src/InstagramScraper/Http/Request.php
  56. +38 −0 src/InstagramScraper/Http/Response.php
  57. +2,550 −506 src/InstagramScraper/Instagram.php
  58. +2 −0 src/InstagramScraper/InstagramQueryId.php
  59. +420 −7 src/InstagramScraper/Model/Account.php
  60. +78 −0 src/InstagramScraper/Model/Activity.php
  61. +157 −0 src/InstagramScraper/Model/ActivityElement.php
  62. +24 −0 src/InstagramScraper/Model/CarouselMedia.php
  63. +68 −0 src/InstagramScraper/Model/Comment.php
  64. +117 −0 src/InstagramScraper/Model/Highlight.php
  65. +81 −0 src/InstagramScraper/Model/Like.php
  66. +139 −6 src/InstagramScraper/Model/Location.php
  67. +499 −75 src/InstagramScraper/Model/Media.php
  68. +146 −0 src/InstagramScraper/Model/ReelMedia.php
  69. +101 −0 src/InstagramScraper/Model/ReelShare.php
  70. +30 −0 src/InstagramScraper/Model/Story.php
  71. +183 −0 src/InstagramScraper/Model/Thread.php
  72. +121 −0 src/InstagramScraper/Model/ThreadItem.php
  73. +73 −0 src/InstagramScraper/Model/UserStories.php
  74. +47 −42 src/InstagramScraper/Traits/ArrayLikeTrait.php
  75. +101 −101 src/InstagramScraper/Traits/InitializerTrait.php
  76. +58 −0 src/InstagramScraper/TwoStepVerification/ConsoleVerification.php
  77. +25 −0 src/InstagramScraper/TwoStepVerification/TwoStepVerificationInterface.php
  78. +95 −13 tests/InstagramTest.php
17 changes: 17 additions & 0 deletions .github/stale.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Number of days of inactivity before an issue becomes stale
daysUntilStale: 60
# Number of days of inactivity before a stale issue is closed
daysUntilClose: 7
# Issues with these labels will never be considered stale
exemptLabels:
- pinned
- security
# Label to use when marking an issue as stale
staleLabel: wontfix
# Comment to post when marking an issue as stale. Set to `false` to disable
markComment: >
This issue has been automatically marked as stale because it has not had
recent activity. It will be closed if no further activity occurs. Thank you
for your contributions.
# Comment to post when closing a stale issue. Set to `false` to disable
closeComment: false
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -4,4 +4,6 @@ composer.phar
composer.lock
.DS_Store
phpunit.phar
tests/sessions
tests/sessions
phpunit.xml
settings.json
1 change: 1 addition & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add getPaginateMediasByLocationId Function
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2016-2019 Raiymbek Kapishev

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
48 changes: 36 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,39 +1,63 @@
# Instagram PHP Scrapper
This library based on Instagram web version. We develop it because nowadays it is hard to get approved Instagram application.
The purpose support every feature that web desktop and mobile version support.
# 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
$instagram = Instagram::withCredentials('username', 'password');
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 does not require auth:

Some methods do not require authentication:
```php
$instagram = new Instagram();
$instagram = new \InstagramScraper\Instagram(new \GuzzleHttp\Client());
$nonPrivateAccountMedias = $instagram->getMedias('kevin');
echo $nonPrivateAccountMedias[0]->getLink();
```
If you use auth it is recommended to cash user session, in this case you don't need run `$instagram->login()` method every time your program runs:

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
$instagram = Instagram::withCredentials('username', 'password', '/path/to/cache/folder/');
$instagram->login(); // will use cached session if you can force login $instagram->login(true)
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
composer.phar require raiym/instagram-php-scraper phpfastcache/phpfastcache
```
or
```sh
composer require raiym/instagram-php-scraper
composer require raiym/instagram-php-scraper phpfastcache/phpfastcache
```

### If you don't have composer
@@ -43,4 +67,4 @@ You can download it [here](https://getcomposer.org/download/).
See examples [here](https://github.com/postaddictme/instagram-php-scraper/tree/master/examples).

## Other
Java library: https://github.com/postaddictme/instagram-java-scraper
Java library: https://github.com/postaddictme/instagram-java-scraper
22 changes: 16 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
@@ -15,16 +15,26 @@
}
],
"require": {
"php": ">=5.4.0",
"mashape/unirest-php": "3.0.*",
"phpFastCache/phpFastCache": "5.0.*"
"php": ">=7.2",
"ext-curl": "*",
"ext-json": "*",
"psr/simple-cache": ">=1.0",
"psr/http-client": "~1.0",
"guzzlehttp/psr7": "^1.7"
},
"require-dev": {
"phpunit/phpunit": "5.5.*"
"phpunit/phpunit": "^7.0",
"phpfastcache/phpfastcache": "^7.1",
"guzzlehttp/guzzle": "^7.2"
},
"autoload": {
"psr-0": {
"InstagramScraper": "src"
"psr-4": {
"InstagramScraper\\": "src/InstagramScraper/"
}
},
"autoload-dev": {
"psr-4": {
"InstagramScraper\\Tests\\": "tests/"
}
},
"support": {
20 changes: 20 additions & 0 deletions examples/addAndDeleteComment.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php
use InstagramScraper\Exception\InstagramException;
use Phpfastcache\Helper\Psr16Adapter;

require __DIR__ . '/../vendor/autoload.php';

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

try {
// add comment to post
$mediaId = '1663256735663694497';
$comment = $instagram->addComment($mediaId, 'Text 1');
// replied to comment
$instagram->addComment($mediaId, 'Text 2', $comment);

$instagram->deleteComment($mediaId, $comment);
} catch (InstagramException $ex) {
echo $ex->getMessage();
}
17 changes: 17 additions & 0 deletions examples/followAndUnfollow.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php
require __DIR__ . '/../../../../vendor/autoload.php';

use InstagramScraper\Instagram;
use Phpfastcache\Helper\Psr16Adapter;

$instagram = Instagram::withCredentials(new \GuzzleHttp\Client(), 'login', 'password', new Psr16Adapter('Files'));
$instagram->login();
$instagram->saveSession();

$account = $instagram->getAccount("username");

$instagram->follow($account->getId());

sleep(10);

$instagram->unfollow($account->getId());
10 changes: 4 additions & 6 deletions examples/getAccountById.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
<?php
require __DIR__ . '/../vendor/autoload.php';

$instagram = \InstagramScraper\Instagram::withCredentials('username', 'password', '/path/to/cache/folder');
$instagram->login();
$account = $instagram->getAccountById('3');
$account = (new \InstagramScraper\Instagram(new \GuzzleHttp\Client()))->getAccountById('3');

// Available fields
echo "Account info:\n";
@@ -14,7 +12,7 @@
echo "Profile picture url: {$account->getProfilePicUrl()}\n";
echo "External link: {$account->getExternalUrl()}\n";
echo "Number of published posts: {$account->getMediaCount()}\n";
echo "Number of followers: {$account->getFollowsCount()}\n";
echo "Number of follows: {$account->getFollowedByCount()}\n";
echo "Number of followers: {$account->getFollowedByCount()}\n";
echo "Number of follows: {$account->getFollowsCount()}\n";
echo "Is private: {$account->isPrivate()}\n";
echo "Is verified: {$account->isVerified()}\n";
echo "Is verified: {$account->isVerified()}\n";
2 changes: 1 addition & 1 deletion examples/getAccountByUsername.php
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@

// If account is public you can query Instagram without auth

$instagram = new \InstagramScraper\Instagram();
$instagram = new \InstagramScraper\Instagram(new \GuzzleHttp\Client());

// For getting information about account you don't need to auth:

6 changes: 4 additions & 2 deletions examples/getAccountFollowers.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<?php
use Phpfastcache\Helper\Psr16Adapter;

require __DIR__ . '/../vendor/autoload.php';

$instagram = \InstagramScraper\Instagram::withCredentials('username', 'password', 'path/to/cache/folder');
$instagram = \InstagramScraper\Instagram::withCredentials(new \GuzzleHttp\Client(), 'username', 'password', new Psr16Adapter('Files'));
$instagram->login();
sleep(2); // Delay to mimic user

@@ -10,4 +12,4 @@
$account = $instagram->getAccount($username);
sleep(1);
$followers = $instagram->getFollowers($account->getId(), 1000, 100, true); // Get 1000 followers of 'kevin', 100 a time with random delay between requests
echo '<pre>' . json_encode($followers, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES) . '</pre>';
echo '<pre>' . json_encode($followers, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES) . '</pre>';
15 changes: 15 additions & 0 deletions examples/getAccountFollowings.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php
use Phpfastcache\Helper\Psr16Adapter;

require __DIR__ . '/../vendor/autoload.php';

$instagram = \InstagramScraper\Instagram::withCredentials(new \GuzzleHttp\Client(), 'username', 'password', new Psr16Adapter('Files'));
$instagram->login();
sleep(2); // Delay to mimic user

$username = 'kevin';
$followers = [];
$account = $instagram->getAccount($username);
sleep(1);
$followers = $instagram->getFollowing($account->getId(), 1000, 100, true); // Get 1000 followings of 'kevin', 100 a time with random delay between requests
echo '<pre>' . json_encode($followers, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES) . '</pre>';
8 changes: 5 additions & 3 deletions examples/getAccountMediasByUsername.php
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
<?php
use Phpfastcache\Helper\Psr16Adapter;

require __DIR__ . '/../vendor/autoload.php';

// If account is public you can query Instagram without auth

$instagram = new \InstagramScraper\Instagram();
$instagram = new \InstagramScraper\Instagram(new \GuzzleHttp\Client());
$medias = $instagram->getMedias('kevin', 25);

// Let's look at $media
$media = $medias[0];

echo "Media info:\n";
echo "Id: {$media->getId()}\n";
echo "Shotrcode: {$media->getShortCode()}\n";
echo "Shortcode: {$media->getShortCode()}\n";
echo "Created at: {$media->getCreatedTime()}\n";
echo "Caption: {$media->getCaption()}\n";
echo "Number of comments: {$media->getCommentsCount()}";
@@ -28,6 +30,6 @@


// If account private you should be subscribed and after auth it will be available
$instagram = \InstagramScraper\Instagram::withCredentials('username', 'password', 'path/to/cache/folder');
$instagram = \InstagramScraper\Instagram::withCredentials(new \GuzzleHttp\Client(), 'username', 'password', new Psr16Adapter('Files'));
$instagram->login();
$medias = $instagram->getMedias('private_account', 100);
34 changes: 22 additions & 12 deletions examples/getCurrentTopMediasByLocationId.php
Original file line number Diff line number Diff line change
@@ -1,24 +1,34 @@
<?php
ini_set('display_errors', 1);ini_set('display_startup_errors', 1);error_reporting(E_ALL);
use Phpfastcache\Helper\Psr16Adapter;

require __DIR__ . '/../vendor/autoload.php';

$instagram = \InstagramScraper\Instagram::withCredentials('username', 'password', '/path/to/cache/folder');
$instagram = \InstagramScraper\Instagram::withCredentials(new \GuzzleHttp\Client(), 'user', 'passwd', new Psr16Adapter('Files'));
$instagram->login();

$medias = $instagram->getCurrentTopMediasByLocationId('1');
$medias = $instagram->getCurrentTopMediasByLocationId('116231');
$media = $medias[0];
echo "Media info:\n";
echo "Id: {$media->getId()}\n";
echo "Shotrcode: {$media->getShortCode()}\n";
echo "Created at: {$media->getCreatedTime()}\n";
echo "Caption: {$media->getCaption()}\n";


$seperator = PHP_SAPI === 'cli' ? "\n" : "<br>\n";
echo "Media info:$seperator";
echo "Id: {$media->getId()}$seperator";
echo "Shortcode: {$media->getShortCode()}$seperator";
echo "Created at: {$media->getCreatedTime()}$seperator";
echo "Caption: {$media->getCaption()}$seperator";
echo "Number of comments: {$media->getCommentsCount()}";
echo "Number of likes: {$media->getLikesCount()}";
echo "Get link: {$media->getLink()}";
echo "High resolution image: {$media->getImageHighResolutionUrl()}";
echo "Media type (video or image): {$media->getType()}";
$account = $media->getOwner();
echo "Account info:\n";
echo "Id: {$account->getId()}\n";
echo "Username: {$account->getUsername()}\n";
echo "Full name: {$account->getFullName()}\n";
echo "Profile pic url: {$account->getProfilePicUrl()}\n";
echo "Account info:$seperator";
echo "Id: {$account->getId()}$seperator";
echo "Username: {$account->getUsername()}$seperator";
echo "Full name: {$account->getFullName()}$seperator";
echo "Profile pic url: {$account->getProfilePicUrl()}$seperator";

echo "<br>";
echo "Location Name: {$media->getLocationName()}$seperator";
echo "Location Slug: {$media->getLocationSlug()}$seperator";
6 changes: 4 additions & 2 deletions examples/getCurrentTopMediasByTagName.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
<?php
use Phpfastcache\Helper\Psr16Adapter;

require __DIR__ . '/../vendor/autoload.php';

$instagram = \InstagramScraper\Instagram::withCredentials('username', 'password', '/path/to/cache/folder');
$instagram = \InstagramScraper\Instagram::withCredentials(new \GuzzleHttp\Client(), 'username', 'password', new Psr16Adapter('Files'));
$instagram->login();

$medias = $instagram->getCurrentTopMediasByTagName('youneverknow');
$media = $medias[0];
echo "Media info:\n";
echo "Id: {$media->getId()}\n";
echo "Shotrcode: {$media->getShortCode()}\n";
echo "Shortcode: {$media->getShortCode()}\n";
echo "Created at: {$media->getCreatedTime()}\n";
echo "Caption: {$media->getCaption()}\n";
echo "Number of comments: {$media->getCommentsCount()}";
15 changes: 15 additions & 0 deletions examples/getFeed.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php
require __DIR__ . '/../../../../vendor/autoload.php';

use InstagramScraper\Instagram;
use Phpfastcache\Helper\Psr16Adapter;

$instagram = Instagram::withCredentials(new \GuzzleHttp\Client(), 'login', 'password', new Psr16Adapter('Files'));
$instagram->login();
$instagram->saveSession();

$posts = $instagram->getFeed();

foreach ($posts as $post){
echo $post->getImageHighResolutionUrl()."\n";
}
Loading