0byt3m1n1
Path:
/
home
/
k
/
a
/
s
/
kassiope
/
www
/
cron
/
[
Home
]
File: instagram.php
<?php session_start(); //ini_set('display_errors',1); include(__DIR__.'/../vendor/autoload.php'); include(__DIR__.'/../configuration.inc.php'); use Phpfastcache\Helper\Psr16Adapter; //############################### // CONFIG //############################### $user = 'lucangeli.it'; $apikey = '23a6bd2d14msh549926420a61ab6p16884bjsn253d52f34d19'; $apikey = '968d45e99bmshff198d417798fdcp1ed80ajsn39bfe2b4f983'; $imgfolder = __DIR__.'/../upload/instagram/'; //############################### $instagram = new \InstagramScraper\Instagram(); $instagram->setRapidApiKey($apikey); $medias = $instagram->getMedias($user, 10); // Let's look at $media foreach($medias as $media) : $img = $media->getImageHighResolutionUrl(); $newimg = $media->getId().'.jpg'; $img_square = $media->getSquareImages(); $newimg_square = $media->getId().'-square.jpg'; $sql = "insert ignore into gaia_instagram (date, url, link, text, img, img_square) values ('".$media->getCreatedTime()."', '".addslashes($img)."', '".addslashes($media->getLink())."', '".addslashes(($media->getCaption()))."' , '".addslashes($newimg)."' , '".addslashes($newimg_square)."' )"; mysql_query_override($sql); //get Hight resolution $ch = curl_init($img); $fp = fopen($imgfolder.'/'.$newimg, 'wb'); curl_setopt($ch, CURLOPT_FILE, $fp); curl_setopt($ch, CURLOPT_HEADER, 0); curl_exec($ch); curl_close($ch); fclose($fp); //get Square resolution $ch = curl_init($img_square[4]); $fp = fopen($imgfolder.'/'.$newimg_square, 'wb'); curl_setopt($ch, CURLOPT_FILE, $fp); curl_setopt($ch, CURLOPT_HEADER, 0); curl_exec($ch); curl_close($ch); fclose($fp); /**/ echo "Media info:<br />"; echo "Id: {$media->getId()}<br />"; echo "Shortcode: {$media->getShortCode()}<br />"; echo "Created at: {$media->getCreatedTime()}<br />"; echo "Caption: {$media->getCaption()}<br />"; echo "Number of comments: {$media->getCommentsCount()}<br />"; echo "Number of likes: {$media->getLikesCount()}<br />"; echo "Get link: {$media->getLink()}<br />"; echo "High resolution image: {$media->getImageHighResolutionUrl()}<br />"; echo "Square resolution image:"; print_r($media->getSquareImages()); echo "<br />"; echo "Media type (video or image): {$media->getType()}<br />"; $account = $media->getOwner(); echo "Account info:<br />"; echo "Id: {$account->getId()}<br />"; echo "Username: {$account->getUsername()}<br />"; echo "Full name: {$account->getFullName()}<br />"; echo "Profile pic url: {$account->getProfilePicUrl()}<br />"; /**/ endforeach; /* $nonPrivateAccountMedias = $instagram->getMedias('lucangeli.it'); echo $nonPrivateAccountMedias[0]->getLink(); print_r($nonPrivateAccountMedias); */ ?>