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';
  • 2
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 12
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 12
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值