NicklasWallgren / instagram-api

Instagram Private API
MIT License
147 stars 47 forks source link

Return list of photos by hash tag. #1

Closed cnizzardini closed 7 years ago

cnizzardini commented 7 years ago

Return list of photos by hash tag.

IG used to allow this via their API but then removed it. If you can add this I'll give it a go on my works website to replace that functionality.

Thanks.

NicklasWallgren commented 7 years ago

I have added initial support for the feed endpoint. I'll finish it up tomorrow and create a new release.

You'll be able to access the feeds and tags methods directly from the Instagram instance in the next commit.

Have a look at Instagram\SDK\Client\Features\HashtagFeaturesTrait

Example

// Retrieve the feed
$feed = $instagram->client->feed('INSERT TAG');

$feed->getRankedItems();
$feed->getItems();

// Retrieve the next batch of items 
$result = $feed->next();
NicklasWallgren commented 7 years ago

https://github.com/NicklasWallgren/instagram-api/tree/v0.7.6

The release was a bit rushed since I'm going away for a few days, so the API might change in future updates.

Feed example

// Retrieve hashtag feed
$message = $instagram->feed('instagram', Instagram::$FEED_TYPE_HASHTAG);

// Output top result
var_dump($message->getRankedItems());

Search example

// Search by hashtag
$message = $instagram->search('instagram', Instagram::$FEED_TYPE_HASHTAG);

// Retrieve the results collection
$result = $message->getResults();

// Pick the first entry
$hashtag = current($result);

// Retrieve the hashtag feed
$feed = $hashtag->getFeed();

// Output items
var_dump($feed->getRankedItems());
cnizzardini commented 7 years ago

Damn, wish I could test this out, but the site I am working on runs off 5.6 and you're using 7.x only language features. I'll test this out again when we get around to upgrading.

NicklasWallgren commented 7 years ago

No worries. Can we close this issue? :)

cnizzardini commented 7 years ago

Your call.

NicklasWallgren commented 7 years ago

Resolved.