-
-
Notifications
You must be signed in to change notification settings - Fork 138
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from pgrimaud/5.0
Release 5.0
- Loading branch information
Showing
30 changed files
with
1,264 additions
and
374 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,12 @@ | ||
.idea | ||
vendor | ||
build | ||
.php_cs.cache | ||
/cache | ||
!/cache/.gitkeep | ||
/tests/cache/ | ||
!/tests/cache/empty/.gitkeep | ||
!/tests/cache/invalid/.gitkeep | ||
!/tests/cache/invalid/demo.cache | ||
!/tests/cache/valid/.gitkeep | ||
!/tests/cache/valid/pgrimaud.cache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,10 @@ | |
{ | ||
"name": "Charles Salvan", | ||
"email": "[email protected]" | ||
}, | ||
{ | ||
"name": "Tim Bond", | ||
"email": "[email protected]" | ||
} | ||
], | ||
"autoload": { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
<?php | ||
|
||
require __DIR__ . '/../vendor/autoload.php'; | ||
|
||
$cache = new Instagram\Storage\CacheManager(); | ||
|
||
$api = new Instagram\Api($cache); | ||
$api->setUserName('pgrimaud'); | ||
|
||
try { | ||
// First page | ||
|
||
/** @var \Instagram\Hydrator\Component\Feed $feed */ | ||
$feed = $api->getFeed(); | ||
|
||
echo '============================' . "\n"; | ||
echo 'User Informations : ' . "\n"; | ||
echo '============================' . "\n\n"; | ||
|
||
echo 'ID : ' . $feed->getId() . "\n"; | ||
echo 'Full Name : ' . $feed->getFullName() . "\n"; | ||
echo 'UserName : ' . $feed->getUserName() . "\n"; | ||
echo 'Following : ' . $feed->getFollowing() . "\n"; | ||
echo 'Followers : ' . $feed->getFollowers() . "\n\n"; | ||
|
||
echo '============================' . "\n"; | ||
echo 'Medias first page : ' . "\n"; | ||
echo '============================' . "\n\n"; | ||
|
||
/** @var \Instagram\Hydrator\Component\Media $media */ | ||
foreach ($feed->getMedias() as $media) { | ||
echo 'ID : ' . $media->getId() . "\n"; | ||
echo 'Caption : ' . $media->getCaption() . "\n"; | ||
echo 'Link : ' . $media->getLink() . "\n"; | ||
echo 'Likes : ' . $media->getLikes() . "\n"; | ||
echo 'Date : ' . $media->getDate()->format('Y-m-d h:i:s') . "\n"; | ||
echo '============================' . "\n"; | ||
} | ||
|
||
// Second Page | ||
|
||
$api->setEndCursor($feed->getEndCursor()); | ||
|
||
sleep(1); // avoir 429 Rate limit from Instagram | ||
|
||
$feed = $api->getFeed(); | ||
|
||
echo "\n\n"; | ||
echo '============================' . "\n"; | ||
echo 'Medias second page : ' . "\n"; | ||
echo '============================' . "\n\n"; | ||
|
||
/** @var \Instagram\Hydrator\Component\Media $media */ | ||
foreach ($feed->getMedias() as $media) { | ||
echo 'ID : ' . $media->getId() . "\n"; | ||
echo 'Caption : ' . $media->getCaption() . "\n"; | ||
echo 'Link : ' . $media->getLink() . "\n"; | ||
echo 'Likes : ' . $media->getLikes() . "\n"; | ||
echo 'Date : ' . $media->getDate()->format('Y-m-d h:i:s') . "\n"; | ||
echo '============================' . "\n"; | ||
} | ||
|
||
// And etc... | ||
|
||
} Catch (\Instagram\Exception\InstagramException $exception) { | ||
print_r($exception->getMessage()); | ||
} | ||
|
||
// Second page |
Oops, something went wrong.