Created
February 14, 2023 11:25
-
-
Save tayfunerbilen/ae0540ae159c09388cacd5da86d044f3 to your computer and use it in GitHub Desktop.
instagram kullanici bilgileri ve son postlari alan kod
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$ch = curl_init(); | |
curl_setopt_array($ch, [ | |
CURLOPT_URL => 'https://www.instagram.com/' . $_GET['username'] . '/embed/', | |
CURLOPT_USERAGENT => 'Mozilla/5.0 (Linux; Android 6.0.1; SM-G935S Build/MMB29K; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/55.0.2883.91 Mobile Safari/537.36', | |
CURLOPT_RETURNTRANSFER => true | |
]); | |
$output = curl_exec($ch); | |
curl_close($ch); | |
$photo = ''; | |
$username = $_GET['username']; | |
$followers = 0; | |
$postCount = 0; | |
$posts = []; | |
$regex = '@\\\"owner\\\":{\\\"id\\\":\\\"([0-9]+)\\\",\\\"profile_pic_url\\\":\\\"(.*?)\\\",\\\"username\\\":\\\"(.*?)\\\",\\\"followed_by_viewer\\\":(true|false),\\\"has_public_story\\\":(true|false),\\\"is_private\\\":(true|false),\\\"is_unpublished\\\":(true|false),\\\"is_verified\\\":(true|false),\\\"edge_followed_by\\\":{\\\"count\\\":([0-9]+)},\\\"edge_owner_to_timeline_media\\\":{\\\"count\\\":([0-9]+)@'; | |
preg_match($regex, $output, $result); | |
if (isset($result[2])) { | |
$photo = str_replace('\\\\\\', '', $result[2]); | |
} | |
if (isset($result[9])) { | |
$followers = $result[9]; | |
} | |
if (isset($result[10])) { | |
$postCount = $result[10]; | |
} | |
preg_match_all('@\\\"thumbnail_src\\\":\\\"(.*?)\\\"@', $output, $result); | |
$posts = array_map(function ($image) { | |
return str_replace('\\\\\\', '', $image); | |
}, array_slice($result[1], 0, 5)); | |
if (!file_exists(__DIR__ . '/' . $username . '.jpg') && $photo) { | |
file_put_contents(__DIR__ . '/' . $username . '.jpg', file_get_contents($photo)); | |
} | |
echo json_encode([ | |
'username' => $username, | |
'photo' => $photo, | |
'followers' => $followers, | |
'postCount' => $postCount, | |
'posts' => $posts | |
]); | |
exit | |
?> | |
<img src="<?= $username ?>.jpg" alt=""> | |
<h3><?= $username ?></h3> | |
<p> | |
Takipci: <?= $followers ?> - Post: <?= $postCount ?> | |
</p> | |
<div> | |
<?php foreach ($posts as $post): ?> | |
<img src="<?= $post ?>" alt=""> | |
<?php endforeach; ?> | |
</div> |
anlamadığım şey bazen çalışıyor bazen çalışmıyor kodda hiç değişiklik yapmıyorum ancak bir çalışıyor bir çalışmıyor anlam veremedim
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Benim için önemli olan takipçi ve gönderi sayısı o kısımda sıkıntı yok. posts kısmında urller çıkıyor ve çalışmıyor.
Neyse birşeyler lazım olursa ham çıktıdan alabilirim. Eline emeğine sağlık. Allah razı olsun.
Videoda /embed yaptığın an olayı bitirdin zaten. İnşaallah kapatmazlar. Güzel keşiflerini bekliyoruz..