kod bu:
<?php
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$post_id = $_POST['post_id'];
$access_token = $_POST['access_token'];
$app_secret = $_POST['app_secret'];
// Appsecret proof oluşturma
$appsecret_proof = hash_hmac('sha256', $access_token, $app_secret);
// Güncel API versiyonu ve appsecret_proof eklendi
$url = "https://graph.instagram.com/v19.0/{$post_id}?access_token={$access_token}&appsecret_proof={$appsecret_proof}";
$data = http_build_query([
'message' => 'Description',
'comment_enabled' => true
]);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Content-Type: application/x-www-form-urlencoded'
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
// Hata kontrolü ve detaylı hata mesajı
if ($httpCode !== 200) {
http_response_code(400);
echo json_encode(['error' => 'Instagram API hatası', 'details' => $result]);
exit;
}
echo json_encode(['success' => true, 'message' => 'Stok durumu güncellendi']);
}