Ürün Medyası
Ürünün galerisini, sipariş görselini ve teslimat dosyasını yöneten on bir uç.
Genel Bakış
Bir ürünün üç ayrı görsel varlığı vardır ve bunlar karıştırılmamalıdır. Galeri birden çok görsel taşır ve sıralanabilir; sipariş görseli tektir ve sipariş ekranında görünür; teslimat dosyası görsel değil, yazılım ürününün müşteriye verdiği dosyadır.
Yükleme uçlarının hiçbiri çok parçalı form beklemez. Dosyayı base64 veri adresi olarak gönderirsiniz ya da indirilebilir bir bağlantı verirsiniz; sunucu adresi kendisi çeker.
Referans
Galeriyi Listeleme
Ürünün galeri görsellerini sıralarına göre döndürür.
photo, header-background, cover ya da mockup.curl 'https://panel.ornek.com/api/v1/admin/products/15/images' \
-H "Authorization: Bearer $API_KEY"const res = await fetch('https://panel.ornek.com/api/v1/admin/products/15/images', {
headers: { Authorization: `Bearer ${apiKey}` },
});
const body = await res.json();$ch = curl_init('https://panel.ornek.com/api/v1/admin/products/15/images');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . $apiKey],
]);
$body = json_decode(curl_exec($ch), true);
curl_close($ch);$response = Api::Products()->GetProductImages(['id' => 15]);{
"data": [
{
"id": 90,
"type": "photo",
"size": "120 KB",
"name": "ab12.jpg",
"url": "https://example.com/uploads/ab12.jpg",
"title": "Screenshot",
"sort_order": 1
}
]
}Galeriye Görsel Yükleme
Galeriye görsel ekler. Dosyayı base64 olarak ya da bir adres vererek gönderirsiniz.
photo, header-background, cover ya da mockup. Varsayılan photo.curl -X POST 'https://panel.ornek.com/api/v1/admin/products/15/images' \
-H "Authorization: Bearer $API_KEY" \
-H 'Content-Type: application/json' \
-d '{"image":"data:image/png;base64,iVBORw0KGgo...","title":"Screenshot"}'const res = await fetch('https://panel.ornek.com/api/v1/admin/products/15/images', {
method: 'POST',
headers: {
Authorization: `Bearer ${apiKey}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
image: 'data:image/png;base64,iVBORw0KGgo...',
title: 'Screenshot',
type: 'photo',
}),
});
const body = await res.json();$data = base64_encode(file_get_contents('screenshot.png'));
$ch = curl_init('https://panel.ornek.com/api/v1/admin/products/15/images');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . $apiKey,
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode([
'image' => 'data:image/png;base64,' . $data,
'title' => 'Screenshot',
]),
]);
$body = json_decode(curl_exec($ch), true);
curl_close($ch);// Yuklenen gorsel galerinin SONUNA eklenir; sirayi ayri bir cagri belirler.
$image = Api::Products()->UploadProductImage([
'id' => 15,
'image' => 'data:image/png;base64,' . base64_encode($bytes),
'title' => 'Screenshot',
]);Görseli Güncelleme
Görselin başlığını ya da rolünü değiştirir. Rol değişince dosya klasörler arasında taşınır.
photo, header-background, cover ya da mockup.curl -X PATCH 'https://panel.ornek.com/api/v1/admin/products/15/images/91' \
-H "Authorization: Bearer $API_KEY" \
-H 'Content-Type: application/json' \
-d '{"title":"Dashboard","type":"cover"}'const res = await fetch('https://panel.ornek.com/api/v1/admin/products/15/images/91', {
method: 'PATCH',
headers: {
Authorization: `Bearer ${apiKey}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({ title: 'Dashboard', type: 'cover' }),
});
const body = await res.json();$ch = curl_init('https://panel.ornek.com/api/v1/admin/products/15/images/91');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'PATCH',
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . $apiKey,
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode([
'title' => 'Dashboard',
'type' => 'cover',
]),
]);
$body = json_decode(curl_exec($ch), true);
curl_close($ch);// Rol degistirmek dosyayi tasir: eski adres artik calismaz.
$response = Api::Products()->UpdateProductImage([
'id' => 15,
'image_id' => 91,
'type' => 'cover',
]);Görseli Silme
Galeriden tek bir görseli siler.
curl -X DELETE 'https://panel.ornek.com/api/v1/admin/products/15/images/91' \
-H "Authorization: Bearer $API_KEY"const res = await fetch('https://panel.ornek.com/api/v1/admin/products/15/images/91', {
method: 'DELETE',
headers: { Authorization: `Bearer ${apiKey}` },
});
const body = await res.json();$ch = curl_init('https://panel.ornek.com/api/v1/admin/products/15/images/91');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'DELETE',
CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . $apiKey],
]);
$body = json_decode(curl_exec($ch), true);
curl_close($ch);$response = Api::Products()->DeleteProductImage([
'id' => 15,
'image_id' => 91,
]);Galeriyi Temizleme
Ürünün tüm galeri görsellerini siler.
curl -X DELETE 'https://panel.ornek.com/api/v1/admin/products/15/images' \
-H "Authorization: Bearer $API_KEY"const res = await fetch('https://panel.ornek.com/api/v1/admin/products/15/images', {
method: 'DELETE',
headers: { Authorization: `Bearer ${apiKey}` },
});
const body = await res.json();$ch = curl_init('https://panel.ornek.com/api/v1/admin/products/15/images');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'DELETE',
CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . $apiKey],
]);
$body = json_decode(curl_exec($ch), true);
curl_close($ch);// Adres tek gorsel silmekle AYNI, fark yalnizca gorsel kimliginin olmamasi.
$response = Api::Products()->ClearProductImages(['id' => 15]);Galeriyi Sıralama
Galeri sırasını verdiğiniz kimlik listesine göre belirler.
photo, header-background, cover ya da mockup.image_ids boş.curl -X PUT 'https://panel.ornek.com/api/v1/admin/products/15/images/order' \
-H "Authorization: Bearer $API_KEY" \
-H 'Content-Type: application/json' \
-d '{"image_ids":[92,90,91]}'const res = await fetch('https://panel.ornek.com/api/v1/admin/products/15/images/order', {
method: 'PUT',
headers: {
Authorization: `Bearer ${apiKey}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({ image_ids: [92, 90, 91] }),
});
const body = await res.json();$ch = curl_init('https://panel.ornek.com/api/v1/admin/products/15/images/order');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . $apiKey,
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode(['image_ids' => [92, 90, 91]]),
]);
$body = json_decode(curl_exec($ch), true);
curl_close($ch);// Bir gorseli one almak icin bile TUM listeyi gonderin.
$ids = array_column(Api::Products()->GetProductImages(['id' => 15])['data'], 'id');
array_unshift($ids, array_pop($ids));
$response = Api::Products()->ReorderProductImages([
'id' => 15,
'image_ids' => $ids,
]);Teslimat Dosyasını Okuma
Yazılım ürününün müşteriye teslim edilen dosyasını döndürür.
curl 'https://panel.ornek.com/api/v1/admin/products/15/delivery-file' \
-H "Authorization: Bearer $API_KEY"const res = await fetch('https://panel.ornek.com/api/v1/admin/products/15/delivery-file', {
headers: { Authorization: `Bearer ${apiKey}` },
});
const body = await res.json();
// Dosya yuklenmemisse data null gelir.
if (body.data === null) return;$ch = curl_init('https://panel.ornek.com/api/v1/admin/products/15/delivery-file');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . $apiKey],
]);
$body = json_decode(curl_exec($ch), true);
curl_close($ch);$response = Api::Products()->GetProductDeliveryFile(['id' => 15]);
$file = $response['data'] ?? null;Teslimat Dosyası Yükleme
Teslimat dosyasını yükler. Önceki dosya kaldırılır; ürün tek bir dosya taşır.
curl -X PUT 'https://panel.ornek.com/api/v1/admin/products/15/delivery-file' \
-H "Authorization: Bearer $API_KEY" \
-H 'Content-Type: application/json' \
-d '{"file":"https://cdn.example.com/setup-v2.zip"}'const res = await fetch('https://panel.ornek.com/api/v1/admin/products/15/delivery-file', {
method: 'PUT',
headers: {
Authorization: `Bearer ${apiKey}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({ file: 'https://cdn.example.com/setup-v2.zip' }),
});
const body = await res.json();$ch = curl_init('https://panel.ornek.com/api/v1/admin/products/15/delivery-file');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . $apiKey,
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode([
'file' => 'https://cdn.example.com/setup-v2.zip',
]),
]);
$body = json_decode(curl_exec($ch), true);
curl_close($ch);// Yeni surum yuklemek eskisini kaldirir — once yedeklemek isteyebilirsiniz.
$response = Api::Products()->UploadProductDeliveryFile([
'id' => 15,
'file' => 'https://cdn.example.com/setup-v2.zip',
]);Teslimat Dosyasını Silme
Teslimat dosyasını kaldırır.
curl -X DELETE 'https://panel.ornek.com/api/v1/admin/products/15/delivery-file' \
-H "Authorization: Bearer $API_KEY"const res = await fetch('https://panel.ornek.com/api/v1/admin/products/15/delivery-file', {
method: 'DELETE',
headers: { Authorization: `Bearer ${apiKey}` },
});
const body = await res.json();$ch = curl_init('https://panel.ornek.com/api/v1/admin/products/15/delivery-file');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'DELETE',
CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . $apiKey],
]);
$body = json_decode(curl_exec($ch), true);
curl_close($ch);$response = Api::Products()->DeleteProductDeliveryFile(['id' => 15]);Sipariş Görselini Ayarlama
Sipariş ekranında görünen görseli ayarlar. Ürün bundan bir tane taşır.
curl -X PUT 'https://panel.ornek.com/api/v1/admin/products/15/order-image' \
-H "Authorization: Bearer $API_KEY" \
-H 'Content-Type: application/json' \
-d '{"image":"https://cdn.example.com/plan.png"}'const res = await fetch('https://panel.ornek.com/api/v1/admin/products/15/order-image', {
method: 'PUT',
headers: {
Authorization: `Bearer ${apiKey}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({ image: 'https://cdn.example.com/plan.png' }),
});
const body = await res.json();$ch = curl_init('https://panel.ornek.com/api/v1/admin/products/15/order-image');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . $apiKey,
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode([
'image' => 'https://cdn.example.com/plan.png',
]),
]);
$body = json_decode(curl_exec($ch), true);
curl_close($ch);$response = Api::Products()->SetProductOrderImage([
'id' => 15,
'image' => 'https://cdn.example.com/plan.png',
]);Sipariş Görselini Silme
Sipariş görselini kaldırır.
curl -X DELETE 'https://panel.ornek.com/api/v1/admin/products/15/order-image' \
-H "Authorization: Bearer $API_KEY"const res = await fetch('https://panel.ornek.com/api/v1/admin/products/15/order-image', {
method: 'DELETE',
headers: { Authorization: `Bearer ${apiKey}` },
});
const body = await res.json();$ch = curl_init('https://panel.ornek.com/api/v1/admin/products/15/order-image');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'DELETE',
CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . $apiKey],
]);
$body = json_decode(curl_exec($ch), true);
curl_close($ch);$response = Api::Products()->DeleteProductOrderImage(['id' => 15]);Tuzaklar
Galeriyi temizleme ile tek görsel silme aynı adresi kullanır; tek fark sondaki görsel kimliğidir. Kimliği boş bir değişkenden kuran kod, silmek istediği tek görsel yerine galerinin tamamını siler.
Sıralama ucu verdiğiniz listeyi sıra olarak kabul eder; listede olmayan görsellerin yeri belirsizleşir. Bir görseli öne almak için bile önce galeriyi okuyup tüm kimlikleri göndermek gerekir. Yeni yüklenen görsel her zaman listenin sonuna eklenir.
Bir görselin rolünü değiştirmek dosyayı klasörler arasında taşır, yani eski adresi çalışmaz hâle gelir. Adresi kendi tarafınızda sakladıysanız güncellemeden sonra yeniden okuyun.
Yeni bir teslimat dosyası yüklemek öncekini kaldırır; ürün aynı anda iki sürüm taşıyamaz. Ayrıca çalıştırılabilir sayfa uzantıları kabul edilmez: sunucuda çalışacak bir dosyayı müşteriye teslim etmenin yolu yoktur.
İlgili Makaleler
Geri bildiriminiz için teşekkürler!
Yukarıda bulamadığınız her şey için destek ekibimiz her zaman yanınızda.