Code restructure push
This commit is contained in:
55
src/pages/events/instapage.php
Normal file
55
src/pages/events/instapage.php
Normal file
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
// Instagram Access Token
|
||||
$accessToken = 'IGQWRPZADdZAUGtMM2NyZADJVSERoSUZA6bVVBV3lKY0dJbWlEcGVvaVYySDViMHMwSkFBQXRVWVQ1ZA080MkRJd0pzYndjWFVTRmtrenBvRml6Vy03NGZAPQ1pROWNKVkJoMTZAid0lIM2htejc3czByajYwMmJHWTBMMTgZD';
|
||||
|
||||
// Instagram API URL to fetch recent media posts
|
||||
$apiUrl = 'https://graph.instagram.com/me/media?fields=id,caption,media_url,thumbnail_url,permalink,media_type&limit=6&access_token=' . $accessToken;
|
||||
|
||||
// Initialize cURL
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, $apiUrl);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||
$response = curl_exec($ch);
|
||||
curl_close($ch);
|
||||
|
||||
// Decode the JSON response
|
||||
$instaFeed = json_decode($response);
|
||||
?>
|
||||
|
||||
<style>
|
||||
.insta-post {
|
||||
display: inline-block;
|
||||
margin: 10px;
|
||||
}
|
||||
|
||||
.insta-post img {
|
||||
width: 200px;
|
||||
height: 200px;
|
||||
overflow: hidden;
|
||||
border-radius: 10px;
|
||||
}
|
||||
</style>
|
||||
<div class="container">
|
||||
<div class="footer-instagram pt-100">
|
||||
<div class="row row-cols-xxl-6 row-cols-xl-5 row-cols-lg-4 row-cols-md-3 row-cols-2">
|
||||
|
||||
<?php
|
||||
// echo "TEST";
|
||||
// Loop through the media and display them
|
||||
if (!empty($instaFeed->data)) {
|
||||
foreach ($instaFeed->data as $post) {
|
||||
// Check if it's an image post
|
||||
if ($post->media_type == 'IMAGE' || $post->media_type == 'CAROUSEL_ALBUM') {
|
||||
echo "<div class='col' data-aos='zoom-in-up' data-aos-duration='1500' data-aos-offset='50'>";
|
||||
echo "<a class='insta-post' href='" . $post->permalink . "' target='_blank'>";
|
||||
echo "<img src='" . $post->media_url . "' alt='" . htmlspecialchars($post->caption) . "'>";
|
||||
echo "</a>";
|
||||
echo "</div>";
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
Reference in New Issue
Block a user