如何使用PHP通过flipkart列表管理api传递批量数据以更新列表属性


How to pass bulk data for update listing attributes with flipkart listing Management api using PHP

我想更新列表属性,如股票折扣t,使用php批量定价。我检查Flipcart api doc https://seller.flipkart.com/api-docs/listing-api-docs/LMAPIRef.html那里我得到了这些参考:

https://api.flipkart.net/sellers/skus/listings/bulk

但是我不知道如何传递参数所需的数据。有人这样做了吗?

你好,从文档它是POST:

Body Parameter: BulkListingRequest (either listingId or skuId is mandatory)
URL: https://api.flipkart.net/sellers/skus/listings/bulk
Headers: Content-type:application/json
Response: BulkStatusOutput

有这样的数据:

{
    "listings": [
    {
        "skuId": "SKUID1",
        "fsn": "FSN1",
        "attributeValues": {
            "mrp": "2400",
            "selling_price": "2300",
            "listing_status": "INACTIVE",
            "fulfilled_by": "seller",
            "national_shipping_charge": "20",
            "zonal_shipping_charge": "20",
            "local_shipping_charge": "20",
            "procurement_sla": "3",
            "stock_count": "23",
            "procurement_type": "REGULAR"
        }
    }
}

所以你需要使用Curl:

$ch = curl_init( $url );
# Setup request to send json via POST.
$dataJson= json_encode($data));
curl_setopt( $ch, CURLOPT_POSTFIELDS, $dataJson);
curl_setopt( $ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json'));
# Return response instead of printing.
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
# Send request.
$result = curl_exec($ch);
curl_close($ch);