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

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

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,962
4년 전 조회 2,972
4년 전 조회 4,123
4년 전 조회 4,832
4년 전 조회 1.2만
4년 전 조회 2,815
4년 전 조회 3,505
4년 전 조회 2,758
4년 전 조회 3,967
4년 전 조회 2,580
4년 전 조회 3,081
4년 전 조회 3,468
4년 전 조회 3,470
4년 전 조회 5,384
4년 전 조회 3,706
4년 전 조회 3,453
4년 전 조회 3,669
4년 전 조회 3,237
4년 전 조회 2,677
4년 전 조회 5,074
4년 전 조회 3,535
4년 전 조회 4,184
4년 전 조회 3,978
4년 전 조회 3,613
4년 전 조회 3,238
4년 전 조회 6,059
4년 전 조회 3,021
4년 전 조회 2,983
4년 전 조회 2,514
4년 전 조회 2,859