• 05-11-2021, 21:20:03
    #1
    Selamlar,

    Arkadaşlar " https://github.com/ismail0234/trendyol-php-api " kütüphane üzerinden APİ Entegrasyonu sağlayarak ürün gönderimi yapmaya çalışıyorum.

    Hazırladığım array
    $json = [
                "items" => [
                      [
                          "barcode" => $product->stocks->sku,
                          "title" => "$product->name",
                          "productMainId" => "$productMainId",
                          "brandId" => $product->trendyolBrand->trend_brand_id,
                          "categoryId" => $product->trendyolCategory->trend_cat_id,
                          "quantity" => $product->stocks->qty,
                          "stockCode" => "$productMainId",
                          "dimensionalWeight" => $product->est_shipping_days,
                          "description" => "$product->description",
                          "currencyType" => "TRY",
                          "listPrice" => $list_price,
                          "salePrice" => $sale_price,
                          "vatRate" => $product->taxes->tax,
                          "cargoCompanyId" => $this->config->cargo_id,
                          "images" => $images,
                          "attributes" => $attribute
                      ]
                ]
            ];
    JSON Olarak çıktısı :

    {
        "items": [
        {
            "barcode": "86814381909941-ERS",
            "title": "Test",
            "productMainId": "TESTURUNYUKLEME",
            "brandId": 4670,
            "categoryId": 1587,
            "quantity": 50,
            "stockCode": "TESTURUNYUKLEME",
            "dimensionalWeight": 2,
            "description": "<p>A\u00e7\u0131klama<\/p>",
            "currencyType": "TRY",
            "listPrice": "11500",
            "salePrice": "9500",
            "vatRate": 18,
            "cargoCompanyId": 3,
            "images": [{"url": "https:\/\/alanadi.com\/public\/uploads\/all\/UrLeCIUVof2HAGNys8FuD1lGKpyTTisZKQLwHdVS.jpg"}],
            "attributes": [
                {"attributeId": 47, "attributeValueId": "Beyaz"},
                {"attributeId": 28, "attributeValueId": 258},
                {"attributeId": 168, "attributeValueId": 1949},
                {"attributeId": 184,"attributeValueId": 2087},
                {"attributeId": 232, "attributeValueId": 4014},
                {"attributeId": 301, "attributeValueId": 3008},
                {"attributeId": 306, "attributeValueId": 3092},
                {"attributeId": 249,"attributeValueId": 3376},
                {"attributeId": 329, "attributeValueId": 19467},
                {"attributeId": 290, "attributeValueId": 4183},
                {"attributeId": 354, "attributeValueId": 7878},
                {"attributeId": 426,"attributeValueId": 19354}
            ]
        }
        ]
    }
    Json olarak da Array olarakda servise gönderdiğimde dönen hata aşağıdadır.


    Konu hakkında bilgisi olan var mıdır?
  • 05-11-2021, 21:29:48
    #2
    Ücretli destek sağlayabilirim.
  • 05-11-2021, 22:54:50
    #3
    KarincaServer adlı üyeden alıntı: mesajı görüntüle
    Selamlar,

    Arkadaşlar " https://github.com/ismail0234/trendyol-php-api " kütüphane üzerinden APİ Entegrasyonu sağlayarak ürün gönderimi yapmaya çalışıyorum.

    Hazırladığım array
    $json = [
                "items" => [
                      [
                          "barcode" => $product->stocks->sku,
                          "title" => "$product->name",
                          "productMainId" => "$productMainId",
                          "brandId" => $product->trendyolBrand->trend_brand_id,
                          "categoryId" => $product->trendyolCategory->trend_cat_id,
                          "quantity" => $product->stocks->qty,
                          "stockCode" => "$productMainId",
                          "dimensionalWeight" => $product->est_shipping_days,
                          "description" => "$product->description",
                          "currencyType" => "TRY",
                          "listPrice" => $list_price,
                          "salePrice" => $sale_price,
                          "vatRate" => $product->taxes->tax,
                          "cargoCompanyId" => $this->config->cargo_id,
                          "images" => $images,
                          "attributes" => $attribute
                      ]
                ]
            ];
    JSON Olarak çıktısı :

    {
        "items": [
        {
            "barcode": "86814381909941-ERS",
            "title": "Test",
            "productMainId": "TESTURUNYUKLEME",
            "brandId": 4670,
            "categoryId": 1587,
            "quantity": 50,
            "stockCode": "TESTURUNYUKLEME",
            "dimensionalWeight": 2,
            "description": "<p>A\u00e7\u0131klama<\/p>",
            "currencyType": "TRY",
            "listPrice": "11500",
            "salePrice": "9500",
            "vatRate": 18,
            "cargoCompanyId": 3,
            "images": [{"url": "https:\/\/alanadi.com\/public\/uploads\/all\/UrLeCIUVof2HAGNys8FuD1lGKpyTTisZKQLwHdVS.jpg"}],
            "attributes": [
                {"attributeId": 47, "attributeValueId": "Beyaz"},
                {"attributeId": 28, "attributeValueId": 258},
                {"attributeId": 168, "attributeValueId": 1949},
                {"attributeId": 184,"attributeValueId": 2087},
                {"attributeId": 232, "attributeValueId": 4014},
                {"attributeId": 301, "attributeValueId": 3008},
                {"attributeId": 306, "attributeValueId": 3092},
                {"attributeId": 249,"attributeValueId": 3376},
                {"attributeId": 329, "attributeValueId": 19467},
                {"attributeId": 290, "attributeValueId": 4183},
                {"attributeId": 354, "attributeValueId": 7878},
                {"attributeId": 426,"attributeValueId": 19354}
            ]
        }
        ]
    }
    Json olarak da Array olarakda servise gönderdiğimde dönen hata aşağıdadır.


    Konu hakkında bilgisi olan var mıdır?
    Hocam title kısmını o şekilde gönderemezsiniz
  • 06-11-2021, 14:29:29
    #4
    OneGui adlı üyeden alıntı: mesajı görüntüle
    Hocam title kısmını o şekilde gönderemezsiniz
    Ürün adı değilde bir kaç değişiklik yaptım. Şimdi de

    Basic Auth hatası veriyor.

    Sıfırdan Curl ile yazdım 500 e atıyor.

    Çözeceğiz inşallah bakalım.
  • 06-11-2021, 18:21:49
    #5
    Gönderdiğiniz header da user-agent bilgisi var mı?
  • 06-11-2021, 18:29:22
    #6
    $requestData = Format::initialize($query, $data);
            $ch = curl_init();
            $header = [];
            curl_setopt($ch, CURLOPT_URL, $this->getApiUrl($requestData));
            curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $this->method);
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
            curl_setopt($ch, CURLOPT_HEADER, false);
            curl_setopt($ch, CURLINFO_HEADER_OUT, true);
            curl_setopt($ch, CURLOPT_TIMEOUT, 20);
    
            curl_setopt($ch, CURLOPT_USERAGENT, $this->userAgent());
    
            if ($authorization) {
                $header[] = 'Authorization: Basic ' . $this->authorization();
            }
    
            if ($this->method == 'POST') {
                $header[] = 'Content-Type: application/json';
                curl_setopt($ch, CURLOPT_POST, 1);
                curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($requestData));
            }
            curl_setopt($ch, CURLOPT_HTTPHEADER,$header);
            $response = trim(curl_exec($ch));
            if (empty($response)) {
                throw new TrendyolException("Trendyol boş yanıt döndürdü.");
            }
    
            $response = json_decode($response);
            curl_close($ch);
            return $response;
  • 09-11-2021, 15:07:20
    #7
    public function sendProduct($product)
    {
    
    $curl = curl_init();
        curl_setopt_array($curl, array(
    CURLOPT_URL => 'https://api.trendyol.com/sapigw/suppliers/MAGAZA-KODU/v2/products',
            CURLOPT_RETURNTRANSFER => true,
            CURLOPT_ENCODING => '',
            CURLOPT_MAXREDIRS => 10,
            CURLOPT_TIMEOUT => 0,
            CURLOPT_FOLLOWLOCATION => true,
            CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
            CURLOPT_CUSTOMREQUEST => 'POST',
            CURLOPT_POSTFIELDS => $product,
            CURLOPT_HTTPHEADER => array(
            'Authorization: Basic Rm04c2xhNFFsTmpzanV6alZhVlY6dmRCWTduekwyejNqUDRSTkZFTkc=',
                'Content-Type: application/json'
            ),
        ));
    
    
        $response = curl_exec($curl);
    
        curl_close($curl);
        return $response;
    Bu fonksiyon ile Örnek Harddisk kategorisine ürün gönderdiğimde sorunsuz yuklenıyor.

    Lakin Dizüstü bilgisayar kategorisine geldiğimde yükleme yapmıyor.

    "{"timestamp":1636458354348,"exception":"ClientApiBusinessException","errors":[{}]}"
    detayları olmayan bu hata exeption dönüyor. Dökümanda bu Exception hakkında hiç birşey yok.


    ------------------------------------------ ÇÖZÜMÜ -------------------------------------------

    {
        [B]"allowCustom": true,[/B]
        "attribute": {
            "id": 47,
            "name": "Renk"
        },
        "attributeValues": [],
        "categoryId": 429,
        "required": true,
        "varianter": false,
        "slicer": true
    }
    Kategori özelliklerinde allowCustom değeri true ise göndereceğiniz değer kısmında attributeValueId değeri yerine customAttributeValue olarak gönderin.

    Sorun bundan ibaret.