Giter Site home page Giter Site logo

pgrimaud / instagram-user-feed Goto Github PK

View Code? Open in Web Editor NEW
835.0 45.0 135.0 1.22 MB

This is a scrapper to easily fetch any feed and interact with Instagram (like, follow, etc.) without OAuth for PHP.

License: MIT License

PHP 100.00%
instagram packagist php instagram-sdk instagram-scraper instagram-feed instagram-client instagram-api checkpoint-challenge-bypass php7

instagram-user-feed's Introduction

Instagram user feed PHP

Build Status Packagist Coverage Status

Minimum PHP Version Last version Total Downloads

All Contributors

Warning 2023-12-31 - Version 7.0.0 will drop support for PHP < 8.2

Warning 2022-11-09 - Instagram changed his DOM AGAIN... Please update to this version 6.16.4

Warning 2022-06-01 - Instagram changed his DOM content and profile data loading. Please update to this version 6.15.0

Information

Easily fetch any Instagram feed and more without OAuth for PHP.

If you like or use this package, please share your love by starring this repository, follow @pgrimaud or become a sponsor. πŸ™πŸ’“

Features

  • Fetch profile data of user
  • Fetch medias of user
  • Fetch stories of user
  • Fetch highlights stories of user
  • Fetch detailed post of user
  • Fetch feed of followers
  • Fetch feed of followings
  • Follow or unfollow users
  • Like or unlike posts
  • Fetch posts of hashtag
  • Fetch comments of a post
  • Fetch live-streaming info
  • Fetch Reels
  • Fetch IGTV
  • Fetch medias where a user has been tagged on
  • Fetch HD profile picture
  • Post a message to a media
  • NEW: Login with cookies πŸŽ‰
  • NEW: Fetch connected user timeline πŸŽ‰

This version can retrieve ANY Instagram feed using web scraping.

⚠️ Version ^5.0 is no more maintained. ⚠️

Installation

composer require pgrimaud/instagram-user-feed

Changelog

v7.0.0 - 2023-12-31:

  • Drop support for PHP < 8.2

v6.16.6 - 2023-12-31:

  • Add support for Symfony 7
  • Fix login error "Unable to extract JSON data" (n1crask)

v6.16.5 - 2023-12-24:

  • Medias are no longer returned after fetching a profile. $profile->getMedias() will always return an empty array after calling $api->getProfile(). It is necessary to call $api->getMoreMedias($profile) to return the first 12 media (cookieguru)
  • Same for IGTV (cookieguru)
  • Fix imap_delete second parameter (deepvision7)

v6.16 - 2022-08-02:

  • Login with cookies. Thanks to nsmle (example here) πŸŽ‰.
  • Fetch connected user timeline. Thanks to nsmle (example here) πŸŽ‰.
  • Add full support for Symfony 6
  • Add checks on missing properties to avoid errors

v6.15 - 2022-06-02:

  • ⚠️ ⚠️ Fix profile endpoint. Please update to this last version!

v6.12 - 2021-09-20:

  • Add method to post message on a media (example here) πŸŽ‰.
  • Add method to get HD profile picture (example here) πŸŽ‰.

v6.11 - 2021-09-13:

  • Add method to fetch medias where a user has been tagged on (example here) πŸŽ‰.

v6.10 - 2021-09-03:

  • Add method to fetch IGTV (example here) πŸŽ‰.
  • Add method to fetch Reels (example here) πŸŽ‰.
  • Split dirty tests in multiple files.

v6.9 - 2021-09-02:

  • Add method to fetch Instagram live-streaming info. Thanks to David-Kurniawan
  • Minor fixes.

v6.8 - 2021-07-08:

v6.7 - 2021-01-31:

  • New feature: get post of hashtag.
  • New feature: get comments of post.
  • Add support for PHP 8.
  • Minor changes and improvements.

v6.6 - 2020-10-06:

  • New feature: like and unlike posts.
  • Retrieval #hashtags and @mentions from stories.
  • Minor changes and improvements.

v6.5 - 2020-09-14:

  • New feature: follow and unfollow users. Thanks to @David-Kurniawan)
  • Minor fixes.

v6.4 - 2020-08-30:

  • New feature: fetch followers and followings feeds. Thanks to @David-Kurniawan)
  • Minor improvements.

v6.3 -2020-07-03:

  • Add checkpoint challenge bypass using IMAP configuration.

v6.2 - 2020-06-01:

  • Improve medias crawling && cache constraints.

v6.1 - 2020-05-21:

  • New feature: Fetch stories and highlights stories.

v6.0 - 2020-05-20

  • Please upgrade from ^5.0 for cookies session stability.

Version ^6.8: strict-origin-when-cross-origin

Facebook added a new CORS policy, and you can't display the data directly.

You can now download media on your storage or server to serve it directly on your website. You can find an example here.

Example:

<?php

// include vendor & classes

// random picture from instagram
$url = 'https://scontent-cdt1-1.cdninstagram.com/v/t51.2885-19/s150x150/156309873_1632221153646196_1273891214497323498_n.jpg?tp=1&_nc_ht=scontent-cdt1-1.cdninstagram.com&_nc_ohc=vbxGNZrjPmUAX8CIDdC&edm=ABfd0MgBAAAA&ccb=7-4&oh=ae5811c07f0e73b945eb203cd58c2101&oe=60EDD1EE&_nc_sid=7bff83'

// define directory
$downloadDir = __DIR__ . '/../assets'; // change it

$fileName = MediaDownloadHelper::downloadMedia($url, $downloadDir);
// file was downloaded here : __DIR__ . '/../assets/v-t51.2885-19-s150x150-156309873_1632221153646196_1273891214497323498_n.jpg

Version ^6.3: Checkpoint challenge bypass

Some people may have trouble to login with this library. It happens for "old" Instagram accounts or if you're using it on some shared hosting (not all, I don't know why...).

You can now automatically bypass the checkpoint challenge. (email verification with code). You can find an example here.

Tips: you should create a dummy instagram account using a dummy e-mailbox to use this feature.

How it works?

  1. The lib will try to login
  2. Got 400 error "checkpoint_required"
  3. Trigger email verification
  4. Connect to your email inbox using IMAP credentials
  5. Wait for Instagram verification email
  6. Parse verification code from email
  7. Make a request to instagram with this code to complete verification
  8. Verification is done, then save session automatically*

*Saving session with cache driver is very important here. The Instagram session is valid for... 1 YEAR. So in theory, using a cache driver and one account will trigger only one real login to Instagram then reusing session for a long time.

Thanks to @ibnux and @eldark for help πŸŽ‰

Version ^6.0: Login

In version ^6.0, login is now mandatory, it will save cookies (session) to simulate "real" requests to Instagram.

They improve their bot detection and without real session data in the headers requests, your IP could be easily soft-ban by Instagram.

Then, you can't fetch a lot of data without login.

Tips: you just have to create or use a dummy account to use easily this package.

Usage

New in 6.0 Cache : This library implements PSR-6 for greatest interoperability.

<?php

use Instagram\Api;
use Symfony\Component\Cache\Adapter\FilesystemAdapter;

$cachePool = new FilesystemAdapter('Instagram', 0, __DIR__ . '/../cache');

$api = new Api($cachePool);
$api->login('username', 'password'); // mandatory
$profile = $api->getProfile('robertdowneyjr');

echo $profile->getUserName(); // robertdowneyjr

echo $profile->getFullName(); // Robert Downey Jr. Official

Basic usage :

<?php

$api = new Api($cachePool);
$api->login('username', 'password');

$profile = $api->getProfile('robertdowneyjr');

print_r($profile);
Instagram\Hydrator\Component\Feed Object
(
    [id] => 1518284433
    [userName] => robertdowneyjr
    [fullName] => Robert Downey Jr. Official
    [biography] => @officialfootprintcoalition @coreresponse
    [followers] => 46382057
    [following] => 50
    [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
    [externalUrl] => http://coreresponse.org/covid19
    [private] => 
    [verified] => 1
    [mediaCount] => 453
        (
            [0] => Instagram\Model\InstagramMedia Object
                (
                    [id] => 2307655221969878423
                    [typeName] => GraphImage
                    [height] => 1350
                    [width] => 1080
                    [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
                    [link] => https://www.instagram.com/p/CAGcDKplv2X/
                    [date] => DateTime Object
                        (
                            [date] => 2020-05-12 22:06:01.000000
                            [timezone_type] => 3
                            [timezone] => Europe/Paris
                        )

                    [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
                    [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
                    [comments] => 3308
                    [likes] => 687988
                    [thumbnails] => Array
                        (
                            [0] => stdClass Object
                                (
                                    [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
                                    [config_width] => 150
                                    [config_height] => 150
                                )

                            [1] => stdClass Object
                                (
                                    [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
                                    [config_width] => 240
                                    [config_height] => 240
                                )

                            [2] => stdClass Object
                                (
                                    [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
                                    [config_width] => 320
                                    [config_height] => 320
                                )

                            [3] => stdClass Object
                                (
                                    [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
                                    [config_width] => 480
                                    [config_height] => 480
                                )

                            [4] => stdClass Object
                                (
                                    [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
                                    [config_width] => 640
                                    [config_height] => 640
                                )

                        )

                    [location] => 
                    [video] => 
                    [videoViewCount] => 0
                )
        ...
        
    [endCursor:Instagram\Model\InstagramProfile:private] => QVFEblBGclVyOEtCMmRLZkVxUUdVbmhsYXNMZmMmplNWtZRkJnRnZOSUdMM1BDRmt3ZA==
)

Paginate

If you want to use paginate on medias, just call getMoreMedias method.

<?php

$api = new Api($cachePool);
$api->login($credentials->getLogin(), $credentials->getPassword());

$profile = $api->getProfile('twhiddleston');

print_r($profile->getMedias()); // 12 first medias

do {
    $profile = $api->getMoreMedias($profile);
    print_r($profile->getMedias()); // 12 more medias

    // avoid 429 Rate limit from Instagram
    sleep(1);
} while ($profile->hasMoreMedias());

Stories

<?php

use Instagram\Api;
use Symfony\Component\Cache\Adapter\FilesystemAdapter;

$cachePool = new FilesystemAdapter('Instagram', 0, __DIR__ . '/../cache');

$api = new Api($cachePool);
$api->login('username', 'password'); // mandatory

$profile = $api->getProfile('starwars'); // we need instagram username
sleep(1);
$feedStories = $api->getStories($profile->getId());

$stories = $feedStories->getStories();

print_r($stories);

Contributors

Thanks goes to these wonderful people (emoji key):

Pierre Grimaud
Pierre Grimaud

πŸ’»
Jan Γ–stlund
Jan Γ–stlund

πŸ’»
Tim Bond
Tim Bond

πŸ’»
Dlinny
Dlinny

πŸ›
RenΓ©
RenΓ©

πŸ›
ikiselev1989
ikiselev1989

πŸ›
Pezhvak
Pezhvak

πŸ’»
David Greminger
David Greminger

πŸ’»
Nana YAMANE
Nana YAMANE

πŸ’»
David Kurniawan
David Kurniawan

πŸ’»
gtapps
gtapps

πŸ’»
Chun-Sheng, Li
Chun-Sheng, Li

⚠️
schelmo
schelmo

πŸ’»
Mojtaba
Mojtaba

πŸ’»
Georgy Gusev
Georgy Gusev

πŸ’»
Jibran Ijaz
Jibran Ijaz

πŸ’»
Julien Cousin-Alliot
Julien Cousin-Alliot

πŸ’»
n-richaud
n-richaud

πŸ›
Dmitry Afonin
Dmitry Afonin

πŸ’»
Andrei Firoiu
Andrei Firoiu

πŸ›
Fiki Pratama
Fiki Pratama

πŸ’»
Carl
Carl

πŸ›
Peter Kampjes
Peter Kampjes

πŸ’»
Bob Brown
Bob Brown

πŸ“–
nagajoomlapro
nagajoomlapro

πŸ’»
cleveng
cleveng

πŸ’»
BMRG14
BMRG14

πŸ’»
Sinan Portakal
Sinan Portakal

πŸ’»
deepvision7
deepvision7

πŸ’»
Yusuf Γ–zdemir
Yusuf Γ–zdemir

πŸ’»
Kadir Melih Can
Kadir Melih Can

πŸ’»

This project follows the all-contributors specification. Contributions of any kind welcome!

Feedback

You found a bug? You need a new feature? You can create an issue if needed or contact me on Twitter.

License

Licensed under the terms of the MIT License.

instagram-user-feed's People

Contributors

allcontributors[bot] avatar andreifiroiu avatar bmrg14 avatar bytehead avatar cleveng avatar cookieguru avatar david-kurniawan avatar deepvision7 avatar dlinny avatar ghostarmy-gabriel avatar goosebumpsos avatar gurubobnz avatar ikiselev1989 avatar jannejava avatar jibran avatar jigexiansen avatar kdrmlhcn avatar kumamidori avatar mnajafzadeh avatar n1crack avatar nagajoomlapro avatar nispeon avatar nsmle avatar peachesontour avatar peter279k avatar pezhvak avatar pgrimaud avatar renedekat avatar schelmo avatar sportakal avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

instagram-user-feed's Issues

version problem installing guzzlehttp/guzzle "^5.0"

Hi, I'm trying to install version "^5.0" (I also tried version "^4.0") and I'm getting this error:

$ composer require pgrimaud/instagram-user-feed "^5.0"

Problem 1
    - pgrimaud/instagram-user-feed 5.1.3 requires guzzlehttp/guzzle ^6.3 -> satisfiable by guzzlehttp/guzzle[6.3.0, 6.3.1, 6.3.2, 6.3.3, 6.3.x-dev] but these conflict with your requirements or minimum-stability.
    - pgrimaud/instagram-user-feed 5.1.2 requires guzzlehttp/guzzle ^6.3 -> satisfiable by guzzlehttp/guzzle[6.3.0, 6.3.1, 6.3.2, 6.3.3, 6.3.x-dev] but these conflict with your requirements or minimum-stability.
    - pgrimaud/instagram-user-feed 5.1.1 requires guzzlehttp/guzzle ^6.3 -> satisfiable by guzzlehttp/guzzle[6.3.0, 6.3.1, 6.3.2, 6.3.3, 6.3.x-dev] but these conflict with your requirements or minimum-stability.
    - pgrimaud/instagram-user-feed 5.1.0 requires guzzlehttp/guzzle ^6.3 -> satisfiable by guzzlehttp/guzzle[6.3.0, 6.3.1, 6.3.2, 6.3.3, 6.3.x-dev] but these conflict with your requirements or minimum-stability.
    - pgrimaud/instagram-user-feed 5.0.1 requires guzzlehttp/guzzle ^6.3 -> satisfiable by guzzlehttp/guzzle[6.3.0, 6.3.1, 6.3.2, 6.3.3, 6.3.x-dev] but these conflict with your requirements or minimum-stability.
    - pgrimaud/instagram-user-feed 5.0.0 requires guzzlehttp/guzzle ^6.3 -> satisfiable by guzzlehttp/guzzle[6.3.0, 6.3.1, 6.3.2, 6.3.3, 6.3.x-dev] but these conflict with your requirements or minimum-stability.
    - Installation request for pgrimaud/instagram-user-feed ^5.0 -> satisfiable by pgrimaud/instagram-user-feed[5.0.0, 5.0.1, 5.1.0, 5.1.1, 5.1.2, 5.1.3].

If I'm not wrong it seems to be that composer is not taking 6.3.0 version as a good version because os the missing "0" in the instagram-user-feed's composer.json ?

Thank you.

Issues on getFeed() with setEndCursor()

Does anyone is getting errors on retrieving the 2nd page of medias (>12)?
I had this working just fine but looks like IG did some changes again.
Not sure how to workaround this.
Thanks

Colon in code example for v5.

In file README.md ("Usage of version ^5.0" section)
print_r($feed): //with a colon
should read
print_r($feed); //With a semicolon

Increase the limit without using Pagination

How to increase the limit of post when i enter the username it show only 12 post but i want to increase the number of post..
So from where i can change the limit of fetching the image..

Thanks in Advance

Undefined property: stdClass::rhx_gis

This morning I noticed a few exceptions have occurred on various instances of sites when calling getFeed(). It looks as if Instagram may have changed some of the available properties and it's now resulting in an undefined property when the method is called:

2019-05-16 11:27:16] production.ERROR: ErrorException: Undefined property: stdClass::$rhx_gis in /home/forge/pura.ae/vendor/pgrimaud/instagram-user-feed/src/Instagram/Transport/HtmlTransportFeed.php:60
Stack trace:
#0 /home/forge/pura.ae/vendor/sentry/sentry/lib/Raven/Breadcrumbs/ErrorHandler.php(34): Illuminate\Foundation\Bootstrap\HandleExceptions->handleError(8, 'Undefined prope...', '/home/forge/pur...', 60, Array)
#1 /home/forge/pura.ae/vendor/pgrimaud/instagram-user-feed/src/Instagram/Transport/HtmlTransportFeed.php(60): Raven_Breadcrumbs_ErrorHandler->handleError(8, 'Undefined prope...', '/home/forge/pur...', 60, Array)
#2 /home/forge/pura.ae/vendor/pgrimaud/instagram-user-feed/src/Instagram/Api.php(74): Instagram\Transport\HtmlTransportFeed->fetchData('pura_food', 12)
#3 /home/forge/pura.ae/app/ViewComposers/InstagramComposer.php(37): Instagram\Api->getFeed()
#4 [internal function]: App\ViewComposers\InstagramComposer->compose(Object(Illuminate\View\View))

pgrimaud/instagram-user-feed v5.4.1

Instagram respond with 429

Hello,
I found your library very useful and I guess it can save my life:) But I have some troubles. Getting the instagram feed on my local machine works perfect, but since I tried it on server machine I always have this error message:
PHP Fatal error: Uncaught exception 'GuzzleHttp\\Exception\\ClientException' with message 'Client error: GET https://www.instagram.com/miamiabeauty/` resulted in a 429 - response:\n\n\n \n <meta http-equiv= (truncated...)\n' in /var/www/html/marketing/public/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php:113\nStack trace:\n#0 /var/www/html/marketing/public/vendor/guzzlehttp/guzzle/src/Middleware.php(66): GuzzleHttp\Exception\RequestException::create(Object(GuzzleHttp\Psr7\Request), Object(GuzzleHttp\Psr7\Response))\n#1 /var/www/html/marketing/public/vendor/guzzlehttp/promises/src/Promise.php(203): GuzzleHttp\Middleware::GuzzleHttp\{closure}(Object(GuzzleHttp\Psr7\Response))\n#2 /var/www/html/marketing/public/vendor/guzzlehttp/promises/src/Promise.php(156): GuzzleHttp\Promise\Promise::callHandler(1, Object(GuzzleHttp\Psr7\Response), Array)\n#3 /var/www/html/marketing/public/vendor/guzzlehttp/promises/src/TaskQueue.php(47): Guz in /var/www/html/marketing/public/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php on line 113`

It shouldn't be request limit issue, because that's just from first request. And I have this trouble only on the server machine, on local machine all fine.
Can you please help me?

Thank you in advance.

New Issue - Guzzle Curl 18

Hello...
Great package, thank you. I'm hitting a consistent error. You can repeat this on:

$api->setUserName('repbarbaracomstock');

When using the end cursor function, it'll work for the first 2-4 times. Then it'll hit this error:

PHP Fatal error: Uncaught GuzzleHttp\Exception\RequestException: cURL error 18: transfer closed with outstanding read data remaining (see http://curl.haxx.se/libcurl/c/libcurl-errors.html) in /home/ubuntu/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php:186

The error is the size returned doesn't match what was reported.

Is there a way to ignore this error? The try/catch doesn't catch this one...

Update. I'm catching the error now. The exception it throws is:
cURL error 18: transfer closed with outstanding read data remaining (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)

The Google recommendation is to ignore the filesize reported if possible.

New instagram hashtags

Hashtags at instagram just changed how they work
Will u provide hashtags scrapper (if it exist in their api)

Set App ID, Client and Secret...

I don't understand one thing... the new Instagram requires an App, then get an access token, then user id to be able to connect to the api.. I am totally wrong? how did you make this? The documentation is so big and confused. sorry

No results anymore, how to debug this? No exception, was working fine for months.

Hi,

ran into this issue that since today I don't get any results anymore, even though I didn't change anything. I checked and the handle is fine and also there is no exception thrown. Then I updated composer packages just to be sure, but nothing changed.

Is this package still working or did Instagram block it?

I am using the default ^5 example code and current release.

$cache = new Instagram\Storage\CacheManager(__DIR__ . '/../../../cache/');
		$api = new Instagram\Api($cache);
		$api->setUserName(get_sub_field( 'instagram_handle' ));
		$instagram_html = "";

		try {
			$feed = $api->getFeed();
			$max_count = get_sub_field( 'amount_of_posts' );
			$i = 0;
			$instagram_html .= '<div class="row">';
			$medias = $feed->getMedias();

			foreach ($medias as $media) {
				$i++;
				$instagram_html .= '<div class="col';
				if($i>3) {
					$instagram_html .= ' d-none d-lg-block';
				} else if($i>2) {
					$instagram_html .= ' d-none d-md-block';
				}
				$instagram_html .= '"><a href="'.$media->getLink().'" target="_blank" title="'.$media->getCaption().'" alt="'.$media->getCaption().'">
				<img class="dshadow" src="/wp-content/themes/understrap-child/img/Rectangle.png" width="100%" style="background-repeat: no-repeat;background-size: cover;background-image:url('.$media->displaySrc.');" /></a></div>';
				if($max_count<=$i) break;
			}
			$instagram_html .= '</div>';
		} catch (Exception $exception) {
			print_r($exception->getMessage());
		} catch (\GuzzleHttp\Exception\GuzzleException $e) {
			print_r($exception->getMessage());
		}
		echo $instagram_html;

graphql query error

Client error: GET https://www.instagram.com/graphql/query/?query_hash=472f257a40c653c64c666ce877d59d2b&first=12&id=4530240674 resulted in a 403 Forbidden response:\n
{"message": "forbidden", "status": "fail"}\

please see this problem

Following

Is there any way to get the list of the following users?

Feed stopped loading - not logged in

Few months before the getFeed() stopped loading the feed. When I debug what Guzzle returns as a html page - it returns the "Login" page, without showing the "username" content. The "fetchData" in HtmlTransportFeed cannot preg_match the <script> code properly, because it's not there.

Interesting is, on my localhost it still works properly. Only server versions stopped fetching the feed correctly.

sidecar images

Hello,
could you please add sidecar image in DisplaySrc? thanks

403 Forbidden

With the new update ( 3.0 ) this error still not fixed. Maybe needs more parameters in to the cookie.

Error with $ProfilePage

Hi, it seems that instagram changed there api, no ?

(ErrorException(code: 0): Undefined property: stdClass::$ProfilePage at /var/www/default/htdocs/vendor/pgrimaud/instagram-user-feed/src/Instagram/Transport/HtmlTransportFeed.php:68)

Set medias number per page

Hey guys,

How can I limit the number of my medias by 10 per "page"? I have 41 medias in total, and I would like paginate by 4 or 5 pages with only 10 medias.

min_id

Use min_id for return media later than this min_id.

Undefined property

Undefined property: stdClass::$ProfilePage in ../vendor/pgrimaud/instagram-user-feed/src/Instagram/Transport/HtmlTransportFeed.php on line 69

Get video media src

  1. Is it possible to get video source for media?
  2. how do you think what is the way do you use for getting media from GraphQl API (temporary available, strongly available, mistakely available)?

paginate problem with 403 forbidden

Hi!

I use the latest release and the first paginate page have forbidden (403). The first getFeed is right, but when is set endcursor and get new feed is alredy wrong. The generated url is:

https://www.instagram.com/graphql/query/?query_hash=42323d64886122307be10013ad2dcc44&variables=%7B%22id%22:%224644890951%22,%22first%22:12,%22after%22:%22QVFES0VFNFhRVUpxVGxaWlh2eW9UTmJSQzVocERFZmhxS3p4aXR6MUtTNE5ibUdiQmV5eHh5UlZHRnFMc2plVDh2RWM0VHdobVgwQ2FhYkotb0ZEZGR3Wg==%22%7D

Getting errors calling getFeed()

Initializing the Api runs without errors, but when calling getFeed() on the api object I get the following warnings, and the feed seems empty.

$cache = new Instagram\Storage\CacheManager('instacache');
$api = new Instagram\Api($cache);
$api->setUserName('garagezuidbroek');
$feed = $api->getFeed();

The list of notices is long, but the first three are:

Notice: Undefined property: stdClass::$ProfilePage in /customers/2/5/3/***.***/httpd.www/m/includes/vendor/pgrimaud/instagram-user-feed/src/Instagram/Transport/HtmlTransportFeed.php on line 60

Notice: Trying to get property 'graphql' of non-object in /customers/2/5/3/***.***/httpd.www/m/includes/vendor/pgrimaud/instagram-user-feed/src/Instagram/Transport/HtmlTransportFeed.php on line 60

Notice: Trying to get property 'user' of non-object in /customers/2/5/3/***.***/httpd.www/m/includes/vendor/pgrimaud/instagram-user-feed/src/Instagram/Transport/HtmlTransportFeed.php on line 60

This is when deploying to shared hosting (one.com), on my own server this exact same code works fine.

Cache expiry time?

Hi!

First I'd like to say THANKS A LOT for this fantastic code!

Now, I need to know how long the cached files will be kept before they will be refreshed automatically by this code?

Smaller thumbnailSrc sizes

Hi,
is there any way to get smaller thumbnailSrc size (150x150 or 240x240) instead of current 640x640?
I am using v5.0.

Thanks

Is the cache system actually working ?

Can you explain how the cache system works ? will it cache the data itself ? i would to avoid making a network connection to instagram whenever possible , in my case for another project i was downloading the data and storing into a cache file, then it would check if the data is older than lets say 4 hours, if so.. get the data remotely...

Great Scraper by the way! Thanks for taking the time!

ssl certificate problem?

Fatal error: Uncaught GuzzleHttp\Exception\RequestException: cURL error 60: SSL certificate problem: unable to get local issuer certificate

Paginate in Version 4

Currently the documentation is written as:

// First call :

$api = new Api();
$api->setUserId(184263228);
$api->setAccessToken('1234578.abcabc.abcabcabcabcabcabcabcabcabcabc');

$feed = $api->getFeed();

$endCursor = $feed->getMaxId();

// Second call : 

$api = new Api();
$api->setUserId(184263228);
$api->setAccessToken('1234578.abcabc.abcabcabcabcabcabcabcabcabcabc');
$api->setMaxId('1230468487398454311_184263228');

$feed = $api->getFeed();

// And etc...

I was wondering if it should read:

$api->setMaxId($endCursor);

and if so, why am I not able to pull more content? ... or ... why am I mistaken?
I'm not certain to the purpose of MaxId, if you can shed some light on what purpose it serves.

Thanks!

Laravel 5 integration Question

Hi Pierre,
Congrats per your work
How can I do to integrate it inside a controller of Laravel?
Do you have some link to check it out.
Thanks!

5.6beta - Send/Enter Security Code

After seeing the IP locked (Ref #45) I am trying 5.6beta.

Although I pass in the correct credentials, it is throwing the exception

Instagram Error: Client error: `POST https://www.instagram.com/accounts/login/ajax/` resulted in a `400 Bad Request` response:
{"message": "checkpoint_required", "checkpoint_url": "/challenge/12345/0lARIAzCSu/", "lock": false, "status": "fail (truncated...)

Also, when I log in manually, it first tries to unlock the IP (?) via a security code sent by Email, I don't think this will work on the server, will it? Can I disable this security feature in my preferences? (Two-Factor-Auth is already disabled.)

Exception Occurred Version ^5.0

Last 2 days it was working properly.
Currently Showing as follows/pgrimaud/instagram-user-feed/src/Instagram/Hydrator/HtmlHydrator.php:33 Invalid argument supplied for foreach() (2)

Instagram new change, error on graphql query

Hello, seems like Instagram might have done a update recently, I'm getting the following error these last few days:
Instagram API Error:Request exception:Client error: `GET https://www.instagram.com/graphql/query/?query_hash=42323d64886122307be10013ad2dcc44&variables=%7B%22id%22:null,%22first%22:12,%22after%22:%22QVFEQVhPbDhGQjZ4OWp2ZGt6cWpNYTlHWVlEMU$
{"message": "execution failure", "errors": [{"message": "execution error", "locations": []}], "status": "fail"}

Any idea?

Thank you,

Fetch data with credentials

Simulate a login process with login and password. Then fetch data with cookie generated with credentials.

414 Request-URI Too Long

Hello i've started to use your project.

foreach ($feed->getMedias() as $media) {
echo '#id#' . $media->getId();
echo "\n";
}
$endCursor = $feed->getEndCursor();
$api->setEndCursor($endCursor);
sleep(2);
echo "page2 " .$endCursor. "\n";

I wrote this code to get user's media page by page. After 3 successful pages i saw this error.

Warning: fread(): SSL: An existing connection was forcibly closed by the remote host.
in C:\php\vendor\guzzlehttp\psr7\src\Stream.php on line 218
PHP Fatal error: Uncaught GuzzleHttp\Exception\ClientException: Client error: GET https://www.instagram.com/graphql/query/?query_hash=42323d64886122307be10013ad2dcc44&variables=%7B%22id%22:%222111407363%22,%22first%22:%2212%22,%22after%22:%22AQCcFWd3FYAs8u_jqqmbpUOj0FikmnibvnzZ9JR7IaSvWpM7OOhThWdaYR0tIVdv6IzqwpJxq_TQup4j0AvxtAZS-CjfpLbIV9wGtsgTTFlncQ%22%7D resulted in a 414 Request-URI Too Long response in C:\php\vendor\guzzlehttp\guzzle\src\Exception\RequestException.php:113
Stack trace:
#0 C:\php\vendor\guzzlehttp\guzzle\src\Middleware.php(66): GuzzleHttp\Exception\RequestException::create(Object(GuzzleHttp\Psr7\Request), Object(GuzzleHttp\Psr7\Response))
#1 C:\php\vendor\guzzlehttp\promises\src\Promise.php(203): GuzzleHttp\Middleware::GuzzleHttp{closure}(Object(GuzzleHttp\Psr7\Response))
#2 C:\php\vendor\guzzlehttp\promises\src\Promise.php(156): GuzzleHttp\Promise\Promise::callHandler(1, Object(GuzzleHttp\Psr7\Response), Array)
#3 C:\php\vendor\guzzlehttp\promises\src\TaskQueue.php(47): GuzzleHttp\Promise\Promise::Guz in C:\php\vendor\guzzlehttp\guzzle\src\Exception\RequestException.php on line 113

I can't parse more than 3 pages from any account. Tried on windows and linux, the result was same. Can you help me?

Was working, now its not

Hello,
Everything was working fine but suddenly stopped. Nothing was changed. What can be the issue?
Got error:
Warning: Invalid argument supplied for foreach() in ...Instagram/Hydrator/HtmlHydrator.php on line 33

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.