postaddictme / instagram-php-scraper

Get account information, photos, videos, stories and comments.
https://packagist.org/packages/raiym/instagram-php-scraper
MIT License
3.08k stars 798 forks source link

Cannot access protected property InstagramScraper\Model\Media #188

Closed danielgc closed 6 years ago

danielgc commented 6 years ago

Hello! I installed via composer (composer require raiym/instagram-php-scraper) and apparently all installed correctly, no errors were shown. But when I try a test like:

` error_reporting(E_ALL); ini_set('display_errors', '1'); require_once 'vendor/autoload.php'; use InstagramScraper\Instagram; use InstagramScraper\Model\Media;

$instagram = Instagram::withCredentials('myuser', 'mypass'); $instagram ->login();

$posts = $instagram->getTopMediasByTagName('smsda');

print_r($posts);

foreach ($posts as $i => $post) { echo ($i) . '. ' . $post->caption . PHP_EOL; } `

I get "Fatal error: Cannot access protected property InstagramScraper\Model\Media::$caption in ... test.php"

the print_r shows me Array ( [0] => InstagramScraper\Model\Media Object ( [id:protected] => 1633578741186982284 [shortCode:protected] => BarozXFFHGM [createdTime:protected] => 1508957782 [type:protected] => image [link:protected] => ...

what am I doing wrong?

Thx so much in advance!

raiym commented 6 years ago

$post->getCaption()

raiym commented 6 years ago

I will change documentation

danielgc commented 6 years ago

wow, thx raiym!

raiym commented 6 years ago

sure