Skip to content

Commit

Permalink
chore(example): tag filtering example (#13)
Browse files Browse the repository at this point in the history
Co-authored-by: George Law <[email protected]>
  • Loading branch information
Yizack and geolaw authored Jan 30, 2025
1 parent 2b273bc commit db3d56d
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions example/feed.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
$feed = new InstagramFeed(
"long-lived-access-token" // Your long-lived-access-token
);

// If a tag is provided, filter posts in the for loop to include only those where the caption contains the tag.
$tag = $_GET['tag'] ?? null;
?>

<html>
Expand All @@ -19,15 +22,14 @@
<div class="glide__track" data-glide-el="track">
<ul class="glide__slides">
<?php
foreach ($feed->getFeed() as $value) {
$username = $value["username"];
$permalink = $value["permalink"];
$timestamp = $value["timestamp"];
$caption = "";

if (isset($value["caption"])) {
$caption = $value["caption"];
foreach ($feed->getFeed() as $item) {
if ($tag && !stripos($item["caption"], $tag)) {
continue;
}
$username = $item["username"];
$permalink = $item["permalink"];
$timestamp = $item["timestamp"];
$caption = $item["caption"] ?? "";
?>
<li class="glide__slide">
<div class="instagram-wrapper">
Expand Down

0 comments on commit db3d56d

Please sign in to comment.