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

时间:2016-08-31 13:13:35

标签: php json api bulkupdate flipkart-api

我希望更新商家信息等列表属性 t,使用 php 批量定价。 我检查 Flipcart api doc https://seller.flipkart.com/api-docs/listing-api-docs/LMAPIRef.html我得到了这些参考:

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

但我不知道如何传递参数所需的数据。有人这样做请回答。

1 个答案:

答案 0 :(得分:0)

你好,文件是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);