경고 2023-12-31 - 버전 7.0.0에서는 PHP < 8.2에 대한 지원이 중단됩니다.
경고 2022-11-09 - Instagram이 DOM을 다시 변경했습니다... 이 버전 6.16.4로 업데이트하세요.
경고 2022-06-01 - Instagram이 DOM 콘텐츠 및 프로필 데이터 로드를 변경했습니다. 이 버전 6.15.0으로 업데이트하세요.
PHP용 OAuth 없이 Instagram 피드 등을 쉽게 가져올 수 있습니다.
이 패키지를 좋아하거나 사용하신다면 이 저장소에 별표를 표시하여 사랑을 공유하거나 @pgrimaud를 팔로우하거나 후원자가 되십시오.
이 버전은 웹 스크래핑을 사용하여 모든 Instagram 피드를 검색할 수 있습니다.
composer require pgrimaud/instagram-user-feed
v7.0.0 - 2023-12-31:
v6.16.6 - 2023-12-31:
v6.16.5 - 2023-12-24:
$profile->getMedias()
$api->getProfile()
호출한 후에 항상 빈 배열을 반환합니다. 처음 12개 미디어(cookieguru)를 반환하려면 $api->getMoreMedias($profile)
호출해야 합니다.v6.16 - 2022-08-02:
v6.15 - 2022-06-02:
v6.12 - 2021-09-20:
v6.11 - 2021-09-13:
v6.10 - 2021-09-03:
v6.9 - 2021-09-02:
v6.8 - 2021-07-08:
v6.7 - 2021-01-31:
v6.6 - 2020-10-06:
v6.5 - 2020-09-14:
v6.4 - 2020-08-30:
v6.3 -2020-07-03:
v6.2 - 2020-06-01:
v6.1 - 2020-05-21:
v6.0 - 2020-05-20
Facebook은 새로운 CORS 정책을 추가했으며 데이터를 직접 표시할 수 없습니다.
이제 스토리지나 서버에 미디어를 다운로드하여 웹사이트에 직접 제공할 수 있습니다. 여기에서 예를 찾을 수 있습니다.
예:
<?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
어떤 사람들은 이 라이브러리에 로그인하는 데 문제가 있을 수 있습니다. 이 문제는 "오래된" Instagram 계정에서 발생하거나 일부 공유 호스팅에서 사용하는 경우 발생합니다(전부는 아니지만 이유는 모르겠습니다...).
이제 체크포인트 챌린지를 자동으로 우회할 수 있습니다. (코드로 이메일 확인). 여기에서 예를 찾을 수 있습니다.
팁: 이 기능을 사용하려면 가짜 이메일을 사용하여 가짜 인스타그램 계정을 만들어야 합니다.
*여기서는 캐시 드라이버로 세션을 저장하는 것이 매우 중요합니다. Instagram 세션의 유효 기간은... 1년 입니다. 따라서 이론적으로 캐시 드라이버와 하나의 계정을 사용하면 Instagram에 대한 실제 로그인이 한 번만 실행되고 오랫동안 세션을 재사용하게 됩니다.
도움을 주신 @ibnux와 @eldark에게 감사드립니다.
^6.0 버전에서는 이제 로그인이 필수 이며 Instagram에 대한 "실제" 요청을 시뮬레이션하기 위해 쿠키(세션)를 저장합니다.
봇 탐지 기능을 개선하고 헤더 요청에 실제 세션 데이터가 없으면 귀하의 IP가 Instagram에서 쉽게 소프트 금지될 수 있습니다.
그러면 로그인하지 않으면 많은 데이터를 가져올 수 없습니다.
팁: 이 패키지를 쉽게 사용하려면 더미 계정을 만들거나 사용해야 합니다.
6.0 캐시의 새로운 기능 : 이 라이브러리는 최고의 상호 운용성을 위해 PSR-6을 구현합니다.
<?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
<?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 ModelInstagramMedia 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:InstagramModelInstagramProfile:private] => QVFEblBGclVyOEtCMmRLZkVxUUdVbmhsYXNMZmMmplNWtZRkJnRnZOSUdMM1BDRmt3ZA==
)
미디어에 페이지 매김을 사용하려면 getMoreMedias
메소드를 호출하면 됩니다.
<?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 ());
<?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 );
다음 멋진 분들에게 감사드립니다(이모지 키):
피에르 그리모 | 얀 외스틀룬드 | 팀 본드 | 들리니 | 르네 | ikiselev1989 | 페즈박 |
데이비드 그레밍거 | 야마네 나나 | 데이비드 커니아완 | gtapps | 리춘성 | 셸모 | 모이타바 |
게오르기 구세프 | 지브란 이자즈 | 줄리앙 커즌-앨리어트 | n-리차우드 | 드미트리 아포닌 | 안드레이 피로이우 | 피키 프라타마 |
칼 | 피터 캄페스 | 밥 브라운 | 나가줌라프로 | 클리벤 | BMRG14 | 시난 포르타칼 |
딥비전7 | 유수프 외즈데미르 | 카디르 멜리 칸 |
이 프로젝트는 모든 기여자 사양을 따릅니다. 어떤 종류의 기여도 환영합니다!
버그를 발견하셨나요? 새로운 기능이 필요하십니까? 필요한 경우 문제를 생성하거나 Twitter에서 저에게 연락할 수 있습니다.
MIT 라이선스 조건에 따라 라이선스가 부여됩니다.