AMAZON SP API Feed
生活随笔
收集整理的這篇文章主要介紹了
AMAZON SP API Feed
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
參考資料
feedType : https://github.com/amzn/selling-partner-api-docs/blob/main/references/feeds-api/feedtype-values.md
使用方法:https://developer-docs.amazon.com/sp-api/docs/feeds-api-v2021-06-30-reference
例:修改Price
1. 先創建 feedDocument
$params = array('contentType' => 'text/xml; charset=UTF-8', ); $method = 'POST'; $path = '/feeds/2021-06-30/documents';// 請求成功時,會返回:
$feedDocumentId;
$url;
2.上傳 xml 文件內容
// XML
$xml = '<?xml version="1.0" encoding="UTF-8"?>'; $xml .= '<AmazonEnvelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="amzn-envelope.xsd">'; $xml .= '<Header>'; $xml .= '<DocumentVersion>1.01</DocumentVersion>'; $xml .= '<MerchantIdentifier>' . $merchant_id . '</MerchantIdentifier>'; $xml .= '</Header>'; $xml .= '<MessageType>Price</MessageType>'; $xml .= '<Message>'; $xml .= '<MessageID>1</MessageID>'; $xml .= '<Price>'; // SELLER SKU $xml .= '<SKU>' . $amazon_seller_sku . '</SKU>'; // 售價 $xml .= '<StandardPrice currency="' . $currencyCode . '">1</StandardPrice>'; // 折扣價 $xml .= '<Sale>'; $xml .= '<StartDate>' . '2020-02-02T00:00:00Z' . '</StartDate>'; $xml .= '<EndDate>' . '2020-02-02T00:00:00Z' . '</EndDate>'; $xml .= '<SalePrice currency="' . $currencyCode . '">1</SalePrice>'; $xml .= '</Sale>'; $xml .= '</Price>'; $xml .= '</Message>'; // 同時修改多個時 $xml .= '<Message>'; $xml .= '<MessageID>2</MessageID>'; $xml .= '<Price>'; // SELLER SKU $xml .= '<SKU>' . $listing['amazon_seller_sku'] . '</SKU>'; // 售價 $xml .= '<StandardPrice currency="' . $currencyCode . '">1</StandardPrice>'; // 折扣價 $xml .= '<Sale>'; $xml .= '<StartDate>' . '2020-02-02T00:00:00Z' . '</StartDate>'; $xml .= '<EndDate>' . '2020-02-02T00:00:00Z' . '</EndDate>'; $xml .= '<SalePrice currency="' . $currencyCode . '">1</SalePrice>'; $xml .= '</Sale>'; $xml .= '</Price>'; $xml .= '</Message>'; $xml .= '</AmazonEnvelope>';$config = array('base_uri' => $url,'headers' => array('Content-Type' => 'text/xml; charset=UTF-8'),'body' => $xml,'http_errors' => false,'verify' => false,'timeout' => 1800 ); $client = new GuzzleHttp\Client($config); $request = $client->request("PUT"); $body = $request->getBody()->getContents(); $httpCode = $request->getStatusCode();'ack' => ($httpCode == 200) ? SUCCESS : FAILURE,3.創建Feed
$params = array('feedType' => 'POST_PRODUCT_PRICING_DATA','marketplaceIds' => array($marketplace_id), // 市場ID'inputFeedDocumentId' => $feedDocumentId ); $method = 'POST'; $path = '/feeds/2021-06-30/feeds';總結
以上是生活随笔為你收集整理的AMAZON SP API Feed的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: gawk详解(一)
- 下一篇: 大学四年的总结与感受