Bu cevap, konu sahibi tarafından kabul edilebilir bir cevap olarak işaretlendi.
Buyur hocam. bu kodu localhostta çalıştırıp işini görürsün diye düşünüyorum çok aşırı id varsa belki proxy lazım olabilir limiti denemedim.
Ekran görüntüsü;
Kod:
<?php
function getUserByUserId($userId) {
$user = [];
if ($userId) {
$baseUrl = "https://i.instagram.com/api/v1/users/{$userId}/info/";
$headers = [
'User-Agent: Mozilla/5.0 (iPhone; CPU iPhone OS 12_3_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 Instagram 105.0.0.11.118 (iPhone11,8; iOS 12_3_1; en_US; en-US; scale=2.00; 828x1792; 165586599)'
];
try {
$ch = curl_init();
curl_setopt_array($ch, [
CURLOPT_URL => $baseUrl,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => $headers,
CURLOPT_SSL_VERIFYPEER => true,
CURLOPT_FOLLOWLOCATION => true
]);
$response = curl_exec($ch);
if (curl_errno($ch)) {
throw new Exception(curl_error($ch));
}
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if ($httpCode !== 200) {
throw new Exception("HTTP request failed with status: " . $httpCode);
}
curl_close($ch);
$userInfo = json_decode($response, true);
if (json_last_error() !== JSON_ERROR_NONE) {
throw new Exception("Failed to parse JSON response");
}
$user = $userInfo['user'] ?? [];
} catch (Exception $e) {
error_log("Getting user failed, due to: " . $e->getMessage());
}
}
return $user;
}
$users = ['317932194', '544022417'];
// $users dizisi içini idler ile doldurun. $users = ['12345', '123456'] gibi. ChatGPT ye idleri liste şeklinde verin bana php array değişkeni olarak ver diyin verir.
foreach($users as $user){
$userInfo = getUserByUserId($user);
if (!empty($userInfo)) {
echo 'USER ID:'. $user. ' USERNAME: '. $userInfo['username']. '</br>';
} else {
echo 'USER ID:'. $user. ' bu id ye ait kullanıcı adı bulunamadı. </br>';
}
}