2

フリップカート API の参照リンク: https://seller.flipkart.com/api-docs/listing-api-docs/LMAPIRef.html#postlisting-label

サンドボックス環境で作業し、サンドボックス API url を使用します。サンドボックス環境でリスティングを作成する方法。本番環境からリストを取得するその他の方法。access_token の生成が成功すると完了します。

enter code here

試した:

私のコード:

error_reporting(E_ALL);

$url  = "https://sandbox-api.flipkart.net/sellers/skus/SKUID/listings";

$curl = curl_init();


$data = '{
            "fsn": "TSHEEG86JGBEABHS",
            "skuId": "P9_30Dec_20000942",
            "attributeValues": {
                "mrp": 140,
                "selling_price": "130",
                "listing_status": "INACTIVE",
                "fulfilled_by": "seller",
                "procurement_sla": "3",
                "stock_count": "23",
                "selling_region_restriction": "none",
                "procurement_type": "REGULAR"
            }
        }';

curl_setopt($curl, CURLOPT_URL,$url);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $data );
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_HTTPHEADER , array('Accept:application/json','Content-type:application/json','Authorization:Bearer '.$access_token));

$result = curl_exec($curl);

$header = curl_getinfo($curl);

echo "Header :<pre>";print_r($header);

echo 'result :';print_r($result);

curl_close($curl);

リクエスト URL : " https://sandbox-api.flipkart.net/sellers/skus/SKUID/listings "

リクエスト :

    '{
                "fsn": "TSHEEG86JGBEABHS",
                "skuId": "P9_30Dec_20000942",
                "属性値": {
                    "mrp": 140,
                    "selling_price": "130",
                    "listing_status": "非アクティブ",
                    "fulfilled_by": "売り手",
                    "調達_sla": "3",
                    "stock_count": "23",
                    "selling_region_restriction": "なし",
                    "調達タイプ": "レギュラー"
                }
            }'

    
Header :
<pre>

[url] => https://sandbox-api.flipkart.net/sellers/skus/SKUID/listings
    [content_type] => text/plain
    [http_code] => 400
    [header_size] => 156
    [request_size] => 687
    [filetime] => -1
    [ssl_verify_result] => 19
    [redirect_count] => 0
    [total_time] => 0.203
    [namelookup_time] => 0
    [connect_time] => 0.047
    [pretransfer_time] => 0.156
    [size_upload] => 485
    [size_download] => 42
    [speed_download] => 206
    [speed_upload] => 2389
    [download_content_length] => 42
    [upload_content_length] => 485
    [starttransfer_time] => 0.203
    [redirect_time] => 0
    [redirect_url] => 
    [primary_ip] => 103.4.255.27
    [certinfo] => Array
        (
        )

    [primary_port] => 443
    [local_ip] => 192.168.1.210
    [local_port] => 50412

応答 : 入力データからオブジェクトを逆シリアル化できません

設定しました

curl_setopt($curl, CURLOPT_HTTPHEADER , array('Accept:application/json');
まだそのショー
[content_type] => テキスト/プレーン
私のヘッダーに。

ヘッダー 'Authorization: Bearer' を設定すると、Content-type がプレーンな /text に変更されます よろしくお願いします。

4

0 に答える 0