인스타그램 좋아요/코멘트 수 읽어오기 > 그누보드5 팁자료실

그누보드5 팁자료실

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

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

본문

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

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 로 읽어와야 할듯요

추천
6
  • 복사

댓글 5개

© SIRSOFT
현재 페이지 제일 처음으로