Instagram Private API library
You can install this by using composer
composer require nicklasw/instagram-api
- Supports asynchronous and parallel requests
- Easily extendable with new requests
- Session and device management
- Access discover feeds (channels, explore, top live)
- Access direct feeds (inbox, thread)
- Much more
use Instagram\SDK\Responses\Exceptions\ApiResponseException;
use Instagram\SDK\DTO\Messages\InboxMessage;
use Instagram\SDK\DTO\Messages\SessionMessage;
use Instagram\SDK\Instagram;
require_once 'vendor/autoload.php';
$instagram = new Instagram();
// Set result mode
$instagram->setMode(Instagram::MODE_PROMISE);
$instagram
->login('INSERT_USERNAME', 'INSERT_PASSWORD')
->then(function (SessionMessage $envelope) use ($instagram) {
return $instagram->inbox();
})->then(function (InboxMessage $envelope) {
// Outputs the threads
var_dump($envelope->getInbox()->getThreads());
})->otherwise(function (ApiResponseException $exception) {
// Outputs the error message
var_dump($exception->getEnvelope()->getMessage());
})
->wait();
use Instagram\SDK\Responses\Exceptions\ApiResponseException;
use Instagram\SDK\DTO\Messages\InboxMessage;
use Instagram\SDK\DTO\Messages\SessionMessage;
use Instagram\SDK\Instagram;
require_once 'vendor/autoload.php';
$instagram = new Instagram();
// Set result mode
$instagram->setMode(Instagram::MODE_PROMISE);
$instagram
->login('INSERT_USERNAME', 'INSERT_PASSWORD')
->wait();
// Flat promise chain
$threads = $instagram
->inbox()
->getInbox()
->getThreads()
->wait();
use Instagram\SDK\DTO\General\ItemType;
use Instagram\SDK\Instagram;
require_once 'vendor/autoload.php';
// Initialize the Instagram library
$instagram = new Instagram();
// Authenticate using username and password
$instagram->login('INSERT_USERNAME', 'INSERT_PASSWORD');
// Invoke the request
$envelope = $instagram->inbox();
// Retrieve the inbox
$inbox = $envelope->getInbox();
// Retrieve the first thread in the inbox
if(!$thread = current($inbox->getThreads())) {
// No thread found
return;
}
// Retrieve the whole thread including thread items
$thread->whole();
// Iterate through the list of items
foreach ($thread->getItems() as $item) {
// Check whether the item is of type media
if ($item->isItemType(ItemType::MEDIA)) {
// Retrieve the images
$images = $item->getMedia()->getImages()->getCandidates();
foreach ($images as $image) {
// Output the image url
var_dump($image->getUrl());
}
}
}
- ApiResponseException
- Generic API response exception, includes envelope
- BadPasswordException
- InvalidUserException
- RateLimitException
- InvalidResponseException
- Generic HTTP response exception
require_once '/vendor/autoload.php';
// Initialize the Instagram library, pass the client
$instagram = new Instagram();
$instagram->setProxyUri('INSERT_PROXY');
// Authenticate using username and password
$envelope = $instagram->login('INSERT_USERNAME', 'INSERT_PASSWORD')->wait();
// Output the response
var_dump($envelope);
- Fork it!
- Create your feature branch:
git checkout -b my-new-feature
- Commit your changes:
git commit -am 'Useful information about your new features'
- Push to the branch:
git push origin my-new-feature
- Submit a pull request
- mgp25 for the inspiration