1. Go to this page and download the library: Download wiensa/n11-sp-api library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
wiensa / n11-sp-api example snippets
use N11Api\N11SpApi\Facades\N11;
// Kategorileri listele
$categories = N11::categories()->getCategories();
// Ürün bilgilerini getir
$product = N11::products()->getProductById(123456);
// Siparişleri listele
$orders = N11::orders()->getOrders([
'status' => 'New',
'period' => [
'startDate' => '01/01/2023',
'endDate' => '31/12/2023'
]
]);
use N11Api\N11SpApi\N11Api;
class ProductController extends Controller
{
protected N11Api $n11;
public function __construct(N11Api $n11)
{
$this->n11 = $n11;
}
public function getProducts()
{
$products = $this->n11->products()->getProducts([
'currentPage' => 0,
'pageSize' => 20
]);
return $products;
}
}
// Tüm kategorileri getir
$categories = N11::categories()->getCategories();
// Kategori detaylarını döngü ile işle
foreach ($categories as $category) {
echo "Kategori ID: " . $category->id . "\n";
echo "Kategori Adı: " . $category->name . "\n";
// Alt kategorileri getir
$subCategories = N11::categories()->getSubCategories($category->id);
// Alt kategorileri işle
foreach ($subCategories as $subCategory) {
echo " Alt Kategori ID: " . $subCategory->id . "\n";
echo " Alt Kategori Adı: " . $subCategory->name . "\n";
}
}
// Ürünü satışa kapat
$result = N11::productSellings()->stopSellingProductByProductId(123456);
// Ürünü satışa aç
$result = N11::productSellings()->startSellingProductByProductId(123456);