Skip to content

Instantly share code, notes, and snippets.

@LeoLopesWeb
Created December 14, 2023 17:21
Show Gist options
  • Save LeoLopesWeb/1b5b9c8702ec4aea541ba7672d9098ce to your computer and use it in GitHub Desktop.
Save LeoLopesWeb/1b5b9c8702ec4aea541ba7672d9098ce to your computer and use it in GitHub Desktop.
<style>
.cabecalho {
width: 100%;
text-align: center;
color: orangered;
}
.cabecalho:hover {
color: blue;
cursor: grab;
text-transform: uppercase;
}
.container {
width: 100%;
margin: 0 auto;
font-family: Verdana, Tahoma, sans-serif;
}
.postagem {
border: 5px solid #f1f1f1;
margin: 10px 10px 1% 1%;
padding: 5px;
width: 29%;
min-height: 650px;
height: auto;
float: left;
border-radius: 15px;
}
.postagem:hover {
border: 5px solid orangered;
}
.titulo {
text-align: center;
margin: 15px;
}
.titulo a,
.titulo a:link,
.titulo a:visited {
font-weight: 600;
font-size: 18px;
color: #00003c;
cursor: alias;
text-decoration: none;
}
.titulo a:hover {
color: red;
text-decoration: none;
text-transform: capitalize;
}
.video {
width: 100%;
display: block !important;
}
.postagem img {
width: 100%;
height: 20rem;
border-radius: 15px;
cursor: grab;
opacity: 1;
}
.postagem img:hover {
opacity: .8;
}
.postagem .descricao {
padding: 15px;
font-size: 14px;
word-wrap: normal;
color: #353535;
cursor: text;
}
.postagem .link-postagem a {
margin-top: 10px;
font-weight: 600;
font-size: 13px;
color: #800000;
cursor: grabbing;
text-decoration: none;
}
.postagem .link-postagem a:hover {
color: red;
cursor: copy;
text-transform: capitalize;
text-decoration: none;
}
.fotodeperfil {
border: 1px solid #353535;
padding: 2px;
border-radius: 50%;
max-width: 30px;
max-height: 30px;
}
</style>
<?php
$campos = "caption,media_type,media_url,permalink,timestamp,username";
$token = "IGQWRQTTh5QmREU05aOTlXTlgxS3N1c2N5TkN3WElLRlNDTXRlT2FSaWNrdnowLUZAILTZARS1FUbGZAtSWkxenAxUmxqYU1qZA2lLS20waEhOT1R6ZAzFuWklaVVFrZAUduTUdDRlAyVmhaVHZAMZA2dYeHNkbEpHRVp4YjAZD";
$limitador = 3;
$stringAPI = "https://graph.instagram.com/me/media?fields={$campos}&access_token={$token}&limit={$limitador}";
$conversaoJsonPHP = @file_get_contents($stringAPI);
$resultadoDecodificado = json_decode($conversaoJsonPHP, true, 512, JSON_BIGINT_AS_STRING);
?>
<?php
echo "<div class='container'>";
foreach ($resultadoDecodificado["data"] as $cp) {
$caption = isset($cp["caption"]) ? $cp["caption"] : "";
$media_type = isset($cp["media_type"]) ? $cp["media_type"] : "";
$media_url = isset($cp["media_url"]) ? $cp["media_url"] : "";
$permalink = isset($cp["permalink"]) ? $cp["permalink"] : "";
$timestamp = isset($cp["timestamp"]) ? $cp["timestamp"] : "";
$username = isset($cp["username"]) ? $cp["username"] : "";
if ($_SERVER["HTTP_HOST"] != "localhost") {
$timestamp = date("d/m/Y h:i", $timestamp);
}
echo "<div class='postagem'>
<div>
<div class='titulo'>
<a href='https://www.instagram.com/{$username}' target='_blank'>
<img class='fotodeperfil' src='./logo-programano.jpg' />
@{$username}
</a>
</div>";
if ($media_type == "VIDEO") {
echo "<video class='video' controls>
<source src='{$media_url}' type='video/mp4' />
Seu navegador não suporta a tag VIDEO
</video>";
} else {
echo "<img src='{$media_url}' />";
}
echo "</div>
<div class='descricao'>
<p><b>Postado:</b> {$timestamp}</p>
<h4>{$caption}</h4>
<div class='link-postagem'>
<a href='{$permalink}' target='_blank'>Ver no Instagram</a>
</div>
</div>
</div>";
}
echo "</div>";
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment