Skip to content

Commit 38052ec

Browse files
committed
Merge 6.0 into master
2 parents e4034f5 + 2f3728e commit 38052ec

49 files changed

Lines changed: 1662 additions & 2371 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,9 @@ composer.lock
22
vendor
33
build
44

5-
.php_cs.cache
5+
examples/credentials.php
66

7-
/cache
8-
!/cache/.gitkeep
7+
!cache/.gitkeep
8+
cache/
99

10-
/tests/cache/
11-
!/tests/cache/empty/.gitkeep
12-
!/tests/cache/invalid/.gitkeep
13-
!/tests/cache/invalid/demo.cache
14-
!/tests/cache/valid/.gitkeep
15-
!/tests/cache/valid/pgrimaud.cache
10+
.phpunit.result.cache

.travis.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
language: php
22

33
php:
4-
- 5.6
5-
- 7.0
6-
- 7.1
74
- 7.2
85
- 7.3
96
- 7.4

README.md

Lines changed: 68 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -3,73 +3,66 @@
33
[![Build Status](https://travis-ci.org/pgrimaud/instagram-user-feed.svg?branch=master)](https://travis-ci.org/pgrimaud/instagram-user-feed)
44
[![Packagist](https://img.shields.io/badge/packagist-install-brightgreen.svg)](https://packagist.org/packages/pgrimaud/instagram-user-feed)
55
[![Coverage Status](https://coveralls.io/repos/github/pgrimaud/instagram-user-feed/badge.svg)](https://coveralls.io/github/pgrimaud/instagram-user-feed)
6+
[![Minimum PHP Version](https://img.shields.io/packagist/php-v/pgrimaud/instagram-user-feed.svg?maxAge=3600)](https://packagist.org/packages/pgrimaud/instagram-user-feed)
67

78
[![Total Downloads](https://poser.pugx.org/pgrimaud/instagram-user-feed/downloads)](https://packagist.org/packages/pgrimaud/instagram-user-feed)
89
[![Monthly Downloads](https://poser.pugx.org/pgrimaud/instagram-user-feed/d/monthly)](https://packagist.org/packages/pgrimaud/instagram-user-feed)
910

10-
## Version ^4.0 is now shutdown ([see](https://support.pixelunion.net/hc/en-us/articles/360041460554-Important-notice-Instagram-feed-removal)). Please upgrade to ^5.0.
11-
1211
## Information
13-
This library offers 2 packages to retrieve your or any Instagram feed without OAuth for PHP.
12+
Easily fetch your or any Instagram feed without OAuth for PHP
13+
14+
**⚠️ Version ^5.0 is no more maintained.**
1415

15-
## Version ^5.0
16+
## Version ^6.0
1617
This version can retrieve **ANY** Instagram feed using **web scrapping**.
1718

18-
- [Installation](#installation-of-version-50)
19-
- [Usage](#usage-of-version-50)
20-
- [Paginate](#paginate-for-version-50)
19+
- [Installation](#installation)
20+
- [Usage](#usage)
21+
- [Paginate](#paginate)
22+
- [Examples](https://github.com/pgrimaud/instagram-user-feed/tree/master/examples)
2123

2224
## Changelog
2325

24-
**2020-02-23 : Version ^4.0 is now shutdown ([see](https://support.pixelunion.net/hc/en-us/articles/360041460554-Important-notice-Instagram-feed-removal)). Please upgrade to ^5.0.**
25-
26-
~~2018-04-20 : Release of version ^5.0 in parallel of version ^4.0 which still working. (Kudos for [@jannejava](https://github.com/jannejava) and [@cookieguru](https://github.com/cookieguru)**)~~
27-
28-
~~2018-04-17 : Now fetching data with screen scraping (thanks [@cookieguru](https://github.com/cookieguru)), please upgrade to version ^5.0~~
26+
**2020-05-21 : Version 6.0 is released. Please upgrade from ^5.0 for cookies session stability.**
2927

30-
~~2018-04-16 : Now fetching data with access token, only for your account (thanks [@jannejava](https://github.com/jannejava)), please upgrade to version ^4.0~~
31-
32-
~~2018-04-08 : Due to changes of the Instagram API (again...), you must upgrade to version ^3.0~~
33-
34-
~~2018-03-16 : Due to changes of the Instagram API, you must upgrade to version ^2.1~~
35-
36-
# Installation of version ^5.0
28+
# Installation
3729

3830
```
3931
composer require pgrimaud/instagram-user-feed
4032
```
4133

42-
## Usage of version ^5.0
34+
## Usage
4335

44-
**New in 5.3** : CacheManager is no more mandatory is you want to retrieve only Instagram profile. (no pagination)
36+
**New in 6.0** Cache : This library implements PSR-6 for greatest interoperability.
4537

4638
```php
47-
$api = new Instagram\Api();
48-
$api->login('username', 'password'); // optional, may be required on shared hosting
49-
$api->setUserName('robertdowneyjr');
39+
<?php
40+
41+
use Instagram\Api;
42+
use Symfony\Component\Cache\Adapter\FilesystemAdapter;
5043

51-
$feed = $api->getFeed();
44+
$cachePool = new FilesystemAdapter('Instagram', 0, __DIR__ . '/../cache');
5245

53-
echo $feed->getUserName();
54-
// robertdowneyjr
46+
$api = new Api($cachePool);
47+
$api->login('username', 'password'); // Mandatory
48+
$profile = $api->getProfile('robertdowneyjr');
5549

56-
echo $feed->getFullName();
57-
// Robert Downey Jr. Official
50+
echo $profile->getUserName(); // robertdowneyjr
5851

52+
echo $profile->getFullName(); // Robert Downey Jr. Official
5953
```
6054

6155
### Basic usage :
6256

63-
6457
```php
65-
$cache = new Instagram\Storage\CacheManager('/path/to/your/cache/folder');
66-
$api = new Instagram\Api($cache);
67-
$api->setUserName('robertdowneyjr');
58+
<?php
6859

69-
$feed = $api->getFeed();
60+
$api = new Api($cachePool);
61+
$api->login('username', 'password');
7062

71-
print_r($feed);
63+
$profile = $api->getProfile('robertdowneyjr');
7264

65+
print_r($profile);
7366
```
7467

7568
```php
@@ -79,67 +72,66 @@ Instagram\Hydrator\Component\Feed Object
7972
[userName] => robertdowneyjr
8073
[fullName] => Robert Downey Jr. Official
8174
[biography] => @officialfootprintcoalition @coreresponse
82-
[followers] => 46338039
75+
[followers] => 46382057
8376
[following] => 50
84-
[profilePicture] => https://scontent-lhr8-1.cdninstagram.com/v/t51.2885-19/s320x320/72702032_542075739927421_3928117925747097600_n.jpg?_nc_ht=scontent-lhr8-1.cdninstagram.com&_nc_ohc=hGF8upBhWgcAX_7ks82&oh=a9cdb3ed313d5c4c9712b52b7d3ceb3f&oe=5EE2E5B8
77+
[profilePicture] => https://scontent-cdt1-1.cdninstagram.com/v/t51.2885-19/s320x320/72702032_542075739927421_3928117925747097600_n.jpg?_nc_ht=scontent-cdt1-1.cdninstagram.com&_nc_ohc=h2zGWoshNjUAX9ze3jb&oh=cf6441cfc3f258da3bf4cfef29686c7d&oe=5EEEC338
8578
[externalUrl] => http://coreresponse.org/covid19
8679
[private] =>
8780
[verified] => 1
88-
[mediaCount] => 452
89-
[medias] => Array
81+
[mediaCount] => 453
9082
(
91-
[0] => Instagram\Hydrator\Component\Media Object
83+
[0] => Instagram\Model\InstagramMedia Object
9284
(
93-
[id] => 2306047234549362565
85+
[id] => 2307655221969878423
9486
[typeName] => GraphImage
95-
[height] => 1080
87+
[height] => 1350
9688
[width] => 1080
97-
[thumbnailSrc] => https://scontent-lhr8-1.cdninstagram.com/v/t51.2885-15/sh0.08/e35/s640x640/96326668_170992687583571_3686185583583090082_n.jpg?_nc_ht=scontent-lhr8-1.cdninstagram.com&_nc_cat=1&_nc_ohc=2qpfvDrHHtwAX9B8mkO&oh=bbd50d5437b7ca52f8e9ba241c358508&oe=5EE38623
98-
[link] => https://www.instagram.com/p/CAAub3qli-F/
89+
[thumbnailSrc] => https://scontent-cdt1-1.cdninstagram.com/v/t51.2885-15/sh0.08/e35/c0.180.1440.1440a/s640x640/96225997_178111910111734_5886065436455432375_n.jpg?_nc_ht=scontent-cdt1-1.cdninstagram.com&_nc_cat=1&_nc_ohc=GqcYpSEbz8gAX_GF1Ep&oh=1b293215142d407faca46a2fd28eab71&oe=5EF0EBDF
90+
[link] => https://www.instagram.com/p/CAGcDKplv2X/
9991
[date] => DateTime Object
10092
(
101-
[date] => 2020-05-10 16:51:14.000000
93+
[date] => 2020-05-12 22:06:01.000000
10294
[timezone_type] => 3
10395
[timezone] => Europe/Paris
10496
)
10597

106-
[displaySrc] => https://scontent-lhr8-1.cdninstagram.com/v/t51.2885-15/e35/s1080x1080/96326668_170992687583571_3686185583583090082_n.jpg?_nc_ht=scontent-lhr8-1.cdninstagram.com&_nc_cat=1&_nc_ohc=2qpfvDrHHtwAX9B8mkO&oh=5afbf701b8374062f15b309247367fc4&oe=5EE51716
107-
[caption] => This Mother’s Day, more than ever, let’s honor the women that raise the children that inherit the Earth #happymothersday
108-
[comments] => 7096
109-
[likes] => 3134975
98+
[displaySrc] => https://scontent-cdt1-1.cdninstagram.com/v/t51.2885-15/e35/p1080x1080/96225997_178111910111734_5886065436455432375_n.jpg?_nc_ht=scontent-cdt1-1.cdninstagram.com&_nc_cat=1&_nc_ohc=GqcYpSEbz8gAX_GF1Ep&oh=6c19ddef96fdc07d7926b05e36cb2bed&oe=5EEED2CE
99+
[caption] => The sweetest things are worth waiting for…Susan and I are producing a @Netflix original series, Sweet Tooth, based on the comic by @Jefflemire. Can’t wait to share it with you all. 🦌 👦 @NXonNetflix @warnerbrostv #SweetTooth
100+
[comments] => 3308
101+
[likes] => 687988
110102
[thumbnails] => Array
111103
(
112104
[0] => stdClass Object
113105
(
114-
[src] => https://scontent-lhr8-1.cdninstagram.com/v/t51.2885-15/e35/s150x150/96326668_170992687583571_3686185583583090082_n.jpg?_nc_ht=scontent-lhr8-1.cdninstagram.com&_nc_cat=1&_nc_ohc=2qpfvDrHHtwAX9B8mkO&oh=d64a87ae9a06f1ae2ac08db593204042&oe=5EE33A86
106+
[src] => https://scontent-cdt1-1.cdninstagram.com/v/t51.2885-15/e35/c0.180.1440.1440a/s150x150/96225997_178111910111734_5886065436455432375_n.jpg?_nc_ht=scontent-cdt1-1.cdninstagram.com&_nc_cat=1&_nc_ohc=GqcYpSEbz8gAX_GF1Ep&oh=24b300201afc0e0c82166c6288e0ed5b&oe=5EF00196
115107
[config_width] => 150
116108
[config_height] => 150
117109
)
118110

119111
[1] => stdClass Object
120112
(
121-
[src] => https://scontent-lhr8-1.cdninstagram.com/v/t51.2885-15/e35/s240x240/96326668_170992687583571_3686185583583090082_n.jpg?_nc_ht=scontent-lhr8-1.cdninstagram.com&_nc_cat=1&_nc_ohc=2qpfvDrHHtwAX9B8mkO&oh=76c8f9337cecbe15615ac46a20973fed&oe=5EE41850
113+
[src] => https://scontent-cdt1-1.cdninstagram.com/v/t51.2885-15/e35/c0.180.1440.1440a/s240x240/96225997_178111910111734_5886065436455432375_n.jpg?_nc_ht=scontent-cdt1-1.cdninstagram.com&_nc_cat=1&_nc_ohc=GqcYpSEbz8gAX_GF1Ep&oh=203d0a3d01d77a2978739c96eb67e607&oe=5EEF6DE0
122114
[config_width] => 240
123115
[config_height] => 240
124116
)
125117

126118
[2] => stdClass Object
127119
(
128-
[src] => https://scontent-lhr8-1.cdninstagram.com/v/t51.2885-15/e35/s320x320/96326668_170992687583571_3686185583583090082_n.jpg?_nc_ht=scontent-lhr8-1.cdninstagram.com&_nc_cat=1&_nc_ohc=2qpfvDrHHtwAX9B8mkO&oh=050d57f21816dfc2f9eb50942eb237af&oe=5EE583F6
120+
[src] => https://scontent-cdt1-1.cdninstagram.com/v/t51.2885-15/e35/c0.180.1440.1440a/s320x320/96225997_178111910111734_5886065436455432375_n.jpg?_nc_ht=scontent-cdt1-1.cdninstagram.com&_nc_cat=1&_nc_ohc=GqcYpSEbz8gAX_GF1Ep&oh=7b9cee64460e1c9c501e59621e6ccfb2&oe=5EF18BE6
129121
[config_width] => 320
130122
[config_height] => 320
131123
)
132124

133125
[3] => stdClass Object
134126
(
135-
[src] => https://scontent-lhr8-1.cdninstagram.com/v/t51.2885-15/e35/s480x480/96326668_170992687583571_3686185583583090082_n.jpg?_nc_ht=scontent-lhr8-1.cdninstagram.com&_nc_cat=1&_nc_ohc=2qpfvDrHHtwAX9B8mkO&oh=dd6e527f2eba91b1d7fc6e0798d49a85&oe=5EE3FE30
127+
[src] => https://scontent-cdt1-1.cdninstagram.com/v/t51.2885-15/e35/c0.180.1440.1440a/s480x480/96225997_178111910111734_5886065436455432375_n.jpg?_nc_ht=scontent-cdt1-1.cdninstagram.com&_nc_cat=1&_nc_ohc=GqcYpSEbz8gAX_GF1Ep&oh=f3d8c31eca2d3c3ab6653b3ed3ebe4f4&oe=5EEFEAC0
136128
[config_width] => 480
137129
[config_height] => 480
138130
)
139131

140132
[4] => stdClass Object
141133
(
142-
[src] => https://scontent-lhr8-1.cdninstagram.com/v/t51.2885-15/sh0.08/e35/s640x640/96326668_170992687583571_3686185583583090082_n.jpg?_nc_ht=scontent-lhr8-1.cdninstagram.com&_nc_cat=1&_nc_ohc=2qpfvDrHHtwAX9B8mkO&oh=bbd50d5437b7ca52f8e9ba241c358508&oe=5EE38623
134+
[src] => https://scontent-cdt1-1.cdninstagram.com/v/t51.2885-15/sh0.08/e35/c0.180.1440.1440a/s640x640/96225997_178111910111734_5886065436455432375_n.jpg?_nc_ht=scontent-cdt1-1.cdninstagram.com&_nc_cat=1&_nc_ohc=GqcYpSEbz8gAX_GF1Ep&oh=1b293215142d407faca46a2fd28eab71&oe=5EF0EBDF
143135
[config_width] => 640
144136
[config_height] => 640
145137
)
@@ -150,33 +142,39 @@ Instagram\Hydrator\Component\Feed Object
150142
[video] =>
151143
[videoViewCount] => 0
152144
)
153-
154145
...
155146

156-
[endCursor] => QVFEMFd3cklmZ3NkZmNjZlA4aTc3LVVOZHpMN1AzZnNBTUF3U3Fjd01KcWVUc25qak40b0Z2UlUzRWVCTzktYU5yOTBLdkduZWR4SC1QTUFQcm93eUtxXw==
147+
[endCursor:Instagram\Model\InstagramProfile:private] => QVFEblBGclVyOEtCMmRLZkVxUUdVbmhsYXNMZmMmplNWtZRkJnRnZOSUdMM1BDRmt3ZA==
157148
)
158149

159150
```
160151

161-
## Paginate for version ^5.0
162-
If you want to use paginate, retrieve `endCursor` from previous call and add it to your next call.
152+
## Paginate
153+
If you want to use paginate on medias, just call `getMoreMedias` method.
163154

164155
```php
165-
// Initialization
156+
<?php
166157

167-
$cache = new Instagram\Storage\CacheManager('/path/to/your/cache/folder');
168-
$api = new Instagram\Api($cache);
169-
$api->setUserName('robertdowneyjr');
158+
$api = new Api($cachePool);
159+
$api->login($credentials->getLogin(), $credentials->getPassword());
170160

171-
// First call :
161+
$profile = $api->getProfile('twhiddleston');
172162

173-
$feed = $api->getFeed();
163+
print_r($profile->getMedias); // 12 first medias
174164

175-
// Second call :
165+
do {
166+
$profile = $api->getMoreMedias($profile);
167+
print_r($profile->getMedias); // 12 more medias
176168

177-
$endCursor = $feed->getEndCursor();
178-
$api->setEndCursor($endCursor);
179-
$feed = $api->getFeed();
180-
181-
// And etc...
169+
// avoid 429 Rate limit from Instagram
170+
sleep(1);
171+
} while ($profile->hasMoreMedias());
182172
```
173+
174+
# Feedback
175+
176+
You found a bug? You need a new feature? You can [create an issue](https://github.com/pgrimaud/horaires-ratp-api/issues) if needed or contact me on [Twitter](https://twitter.com/pgrimaud_).
177+
178+
# License
179+
180+
Licensed under the terms of the MIT License.

composer.json

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,14 @@
22
"name": "pgrimaud/instagram-user-feed",
33
"type": "library",
44
"description": "Easily fetch any user's Instagram feed without OAuth for PHP",
5-
"keywords": ["instagram", "api", "php", "feed", "social", "sdk"],
5+
"keywords": [
6+
"instagram",
7+
"api",
8+
"php",
9+
"feed",
10+
"social",
11+
"sdk"
12+
],
613
"homepage": "https://github.com/pgrimaud/instagram-user-feed",
714
"license": "MIT",
815
"authors": [
@@ -24,14 +31,21 @@
2431
"Instagram\\": "src/Instagram/"
2532
}
2633
},
34+
"autoload-dev": {
35+
"psr-4": {
36+
"Instagram\\Tests\\": "tests/"
37+
}
38+
},
2739
"require": {
40+
"php": "^7.2.5",
2841
"ext-curl": "*",
2942
"ext-json": "*",
30-
"guzzlehttp/guzzle": "^6.3"
43+
"symfony/cache": "^5.0",
44+
"guzzlehttp/guzzle": "^6.5"
3145
},
3246
"require-dev": {
33-
"phpunit/phpunit": "^5.7",
34-
"friendsofphp/php-cs-fixer": "^2.4",
35-
"php-coveralls/php-coveralls": "^2.0"
47+
"php-coveralls/php-coveralls": "^2.2",
48+
"phpunit/phpunit": "^8.5",
49+
"symfony/var-dumper": "^5.0"
3650
}
3751
}

examples/credentials.php.dist

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
return new class('login', 'password') {
4+
5+
private $login;
6+
private $password;
7+
8+
public function __construct(string $login, string $password)
9+
{
10+
$this->login = $login;
11+
$this->password = $password;
12+
}
13+
14+
public function getLogin(): string
15+
{
16+
return $this->login;
17+
}
18+
19+
public function getPassword(): string
20+
{
21+
return $this->password;
22+
}
23+
};

0 commit comments

Comments
 (0)