Instagram parser
Parse Instagram pages without API access.
Installation
composer require 'pavel-krulov/insta-parser'
Usage
Iterate Media From Location
$instaParser = new InstaParser();
$instagramLocationId = 169931983464794;
$aMediaNodes = $instaParser->getMediaByLocation($instagramLocationId, strtotime("2018-05-20 18:00:00"), 35);
$i=0;
foreach ( $aMediaNodes as $oMediaNode) {
/** @var $oMediaNode MediaNode */
print "==== ".(++$i).". =======================";
print $oMediaNode->getId() . PHP_EOL;
print $oMediaNode->getDisplayUrl() . PHP_EOL;
print $oMediaNode->getCaption() . PHP_EOL;
print $oMediaNode->isVideo()?"video":'photo' . PHP_EOL;
print $oMediaNode->getOwnerId() . PHP_EOL;
print $oMediaNode->getDimensions(MediaNode::WIDTH) . 'x'.$oMediaNode->getDimensions(MediaNode::HEIGHT) . PHP_EOL;
print 'Added '. date('Y-m-d H:i:s', $oMediaNode->timeTaken()) . PHP_EOL;
if($shortcode = $oMediaNode->getShortcodeMedia()) {
print '=== shortcode' .PHP_EOL;
print "\tid = ".$shortcode->shortcode . PHP_EOL;
print "\tis_video = ".$shortcode->is_video . PHP_EOL;
print "\tvideo_url = ".$shortcode->video_url . PHP_EOL;
print "\t".$shortcode->getCaption() . PHP_EOL;
}
print "========================================";
print PHP_EOL;
}
Iterate Media By Tagname
$instaParser = new InstaParser();
$tag = 'похудение';
$aMediaNodes = $instaParser->getMediaByTag($tag, strtotime("-2 days"), 15);
$i=0;
foreach ( $aMediaNodes as $oMediaNode) {
/** @var $oMediaNode MediaNode */
print "==== ".(++$i).". =======================";
print $oMediaNode->getId() . PHP_EOL;
print $oMediaNode->getDisplayUrl() . PHP_EOL;
print $oMediaNode->getCaption() . PHP_EOL;
print $oMediaNode->isVideo()?"video":'photo' . PHP_EOL;
print $oMediaNode->getOwnerId() . PHP_EOL;
print $oMediaNode->getDimensions(MediaNode::WIDTH) . 'x'.$oMediaNode->getDimensions(MediaNode::HEIGHT) . PHP_EOL;
print 'Added '. date('Y-m-d H:i:s', $oMediaNode->timeTaken()) . PHP_EOL;
if($shortcode = $oMediaNode->getShortcodeMedia()) {
print '=== shortcode' .PHP_EOL;
print "\tid = ".$shortcode->shortcode . PHP_EOL;
print "\tis_video = ".$shortcode->is_video . PHP_EOL;
print "\tvideo_url = ".$shortcode->video_url . PHP_EOL;
print "\t".$shortcode->getCaption() . PHP_EOL;
}
print "========================================";
print PHP_EOL;
}
Search Tags
$instaParser = new InstaParser();
$tag = 'похудение';
$aTags = $instaParser->searchTags($tag);
$i=0;
foreach ( $aTags as $oSearchTag) {
print (++$i)."__ ";
print 'Instagramm Id: '. $oSearchTag->getInstagramId() . '; ';
print 'Media Count: '. $oSearchTag->getMediaCount() . '; ';
print 'Tagname: '. $oSearchTag->getName() . '; ';
print PHP_EOL;
}