인스타그램 좋아요/코멘트 수 읽어오기

물론 오픈 소스입니다. 그거 다 적용시켜 봣네요

https://github.com/postaddictme/instagram-php-scraper 와  https://github.com/guzzle/guzzle 이용하면 됩니다.

 

실제 서버에 설치한다고 했을때,

mkdir /public_html/lib/insta

cd /public_html/lib/insta

 

composer require raiym/instagram-php-scraper phpfastcache/phpfastcache
composer require guzzlehttp/guzzle

이러면 /public_html/insta/vendor  디렉토리가 생길겁니다.

 

이후 

<?php

use Phpfastcache\Helper\Psr16Adapter;
include_once './lib/insta/vendor/autoload.php';

// If account is public you can query Instagram without auth
$instagram = new \InstagramScraper\Instagram(new \GuzzleHttp\Client());

// If account is private and you subscribed to it, first login
//$instagram = \InstagramScraper\Instagram::withCredentials(new \GuzzleHttp\Client(), 'username', 'password', new Psr16Adapter('Files'));
//$instagram->login();

$media = $instagram->getMediaByUrl('https://www.instagram.com/p/BHaRdodBouH');
echo "Media info:\n";
echo "Id: {$media->getId()}\n";
echo "Shortcode: {$media->getShortCode()}\n";
echo "Created at: {$media->getCreatedTime()}\n";
echo "Caption: {$media->getCaption()}\n";
echo "Number of comments: {$media->getCommentsCount()}";
echo "Number of likes: {$media->getLikesCount()}";
echo "Get link: {$media->getLink()}";
echo "video views: {$media->getVideoViews()}";
echo "High resolution image: {$media->getImageHighResolutionUrl()}";
echo "Media type (video or image): {$media->getType()}";
$account = $media->getOwner();
echo "Account info:\n";
echo "Id: {$account->getId()}\n";
echo "Username: {$account->getUsername()}\n";
echo "Full name: {$account->getFullName()}\n";
echo "Profile pic url: {$account->getProfilePicUrl()}\n";

?>

 

속도는 5초정도 걸리는군요

 

ajax 로 읽어와야 할듯요

|

댓글 5개

좋은 정보네요 감사합니다.
댓글을 작성하시려면 로그인이 필요합니다.

그누보드5 팁자료실

+
제목 글쓴이 날짜 조회
4년 전 조회 3,847
4년 전 조회 2,889
4년 전 조회 4,022
4년 전 조회 4,735
4년 전 조회 1.2만
4년 전 조회 2,726
4년 전 조회 3,409
4년 전 조회 2,664
4년 전 조회 3,833
4년 전 조회 2,494
4년 전 조회 3,007
4년 전 조회 3,379
4년 전 조회 3,371
4년 전 조회 5,291
4년 전 조회 3,620
4년 전 조회 3,352
4년 전 조회 3,589
4년 전 조회 3,147
4년 전 조회 2,590
4년 전 조회 4,976
4년 전 조회 3,430
4년 전 조회 4,095
4년 전 조회 3,883
4년 전 조회 3,511
4년 전 조회 3,153
4년 전 조회 5,946
4년 전 조회 2,931
4년 전 조회 2,907
4년 전 조회 2,431
4년 전 조회 2,768