MWS是商城网络服务的缩写,具体介绍看这里http://docs.developer.amazonservices.com/zh_CN/dev_guide/DG_IfNew.html。MWS就是一组API,提供给开发者调用,实现卖家的数据上传、获取报告、库存、订单等。上面的贴出来的链接里有关于MWS开发者的详细说明,建议先好好通读下“程序员开发指南”,先了解下需要怎么去拼接请求地址和必传参数,否则会走很多弯路。

  在构造一个请求MWS的url之前,你必须得有一个卖家ID(merchantId),如果你自己就是卖家,那么就拿你的卖家ID去注册一个开发者账号,亚马逊会给你一个开发者ID、一个访问秘钥ID(accessKeyId)和一个访问秘钥(secretAccessKey),我们只需要用到3个信息:merchantId、accessKeyId和secretAccessKey。如果卖家是你的朋友,那么同上,由他去注册开发者账号,把这3个信息给你即可。如果是第三方开发者(他已经自己注册了开发者账号),那么卖家需要拿第三方开发者的账号进行授权,授权他能访问卖家账号,这种情况需要把授权令牌(sellerDevAuthToken)拼接到请求地址中。最后作为开发者,你还得知道卖家的MWS究竟是在哪个国家开的,是在美国,欧洲,还是中国?每个地方对应不同的链接地址。

  亚马逊 MWS 文档 » 程序开发员指南 » 亚马逊 MWS Scratchpad(测试工具),点开之后有不同国家MWS对应测试链接,可以要求把对应的参数输进去,看下API返回信息对不对。假设我的店开在中国区,那么就到https://developer.amazonservices.com.cn/这里去点开“导航 -> 亚马逊 MWS Scratchpad(测试工具)”。如果是国外的MWS会慢一些,毕竟传输路径比较长嘛。假如我现在是在北美注册的卖家账号,那么点开https://developer.amazonservices.com(等待n秒) -> Amazon MWS Scratchpad -> SellerId填merchantId、AWSAccessKeyId填accessKeyId、Secret Key填secretAccessKey -> 最后选对应API操作后,点击提交即可。

  如果你想下载客户端代码,直接点开“API与文档 -> 报告(随便点开一个接口即可)-> Java客户端(选择你想要的语言)-> download”。下好了代码直接就拿来主义好了,改改上面的请求字段就可以跑起来了,看一下获取报告条数的API:

/*******************************************************************************
* Copyright 2009 Amazon Services.
* Licensed under the Apache License, Version 2.0 (the "License");
*
* You may not use this file except in compliance with the License.
* You may obtain a copy of the License at: http://aws.amazon.com/apache2.0
* This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
* CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
* *****************************************************************************
*
* Marketplace Web Service Java Library
* API Version: 2009-01-01
* Generated: Wed Feb 18 13:28:48 PST 2009
*
*/ package com.amazonaws.mws.samples; import java.util.List;
import java.util.ArrayList;
import com.amazonaws.mws.*;
import com.amazonaws.mws.model.*;
import com.amazonaws.mws.mock.MarketplaceWebServiceMock; /**
*
* Get Report Count Samples
*
*
*/
public class GetReportCountSample { /**
* Just add a few required parameters, and try the service
* Get Report Count functionality
*
* @param args unused
*/
public static void main(String... args) { /************************************************************************
* Access Key ID and Secret Access Key ID, obtained from:
* http://aws.amazon.com
***********************************************************************/
final String accessKeyId = "WWWWWWLLLLLLFFFFFFFF";
final String secretAccessKey = "WWWWWWLLLLLLFFFFFFFFWWWWWWLLLLLLFFFFFFFF"; final String appName = "AmazonJavascriptScratchpad";
final String appVersion = "1.0"; MarketplaceWebServiceConfig config = new MarketplaceWebServiceConfig(); /************************************************************************
* Uncomment to set the appropriate MWS endpoint.
************************************************************************/
// US
config.setServiceURL("https://mws.amazonservices.com/");
// UK
// config.setServiceURL("https://mws.amazonservices.co.uk/");
// Germany
// config.setServiceURL("https://mws.amazonservices.de/");
// France
// config.setServiceURL("https://mws.amazonservices.fr/");
// Italy
// config.setServiceURL("https://mws.amazonservices.it/");
// Japan
// config.setServiceURL("https://mws.amazonservices.jp/");
// China
// config.setServiceURL("https://mws.amazonservices.com.cn/");
// Canada
// config.setServiceURL("https://mws.amazonservices.ca/");
// India
// config.setServiceURL("https://mws.amazonservices.in/"); /************************************************************************
* The argument (35) set below is the number of threads client should
* spawn for processing.
***********************************************************************/ config.setMaxAsyncThreads(35); /************************************************************************
* You can also try advanced configuration options. Available options are:
*
* - Signature Version
* - Proxy Host and Proxy Port
* - User Agent String to be sent to Marketplace Web Service
*
***********************************************************************/ /************************************************************************
* Instantiate Http Client Implementation of Marketplace Web Service
***********************************************************************/ MarketplaceWebService service = new MarketplaceWebServiceClient(
accessKeyId, secretAccessKey, appName, appVersion, config); /************************************************************************
* Uncomment to try out Mock Service that simulates Marketplace Web Service
* responses without calling Marketplace Web Service service.
*
* Responses are loaded from local XML files. You can tweak XML files to
* experiment with various outputs during development
*
* XML files available under com/amazonaws/mws/mock tree
*
***********************************************************************/
// MarketplaceWebService service = new MarketplaceWebServiceMock(); /************************************************************************
* Setup request parameters and uncomment invoke to try out
* sample for Get Report Count
***********************************************************************/ /************************************************************************
* Marketplace and Merchant IDs are required parameters for all
* Marketplace Web Service calls.
***********************************************************************/
final String merchantId = "WWWWLLLLLFFFFF";
final String sellerDevAuthToken = "<Merchant Developer MWS Auth Token>"; GetReportCountRequest request = new GetReportCountRequest();
request.setMerchant( merchantId );
//request.setMWSAuthToken(sellerDevAuthToken); // @TODO: set request parameters here invokeGetReportCount(service, request); } /**
* Get Report Count request sample
* returns a count of reports matching your criteria;
* by default, the number of reports generated in the last 90 days,
* regardless of acknowledgement status
*
* @param service instance of MarketplaceWebService service
* @param request Action to invoke
*/
public static void invokeGetReportCount(MarketplaceWebService service, GetReportCountRequest request) {
try { GetReportCountResponse response = service.getReportCount(request); System.out.println ("GetReportCount Action Response");
System.out.println ("=============================================================================");
System.out.println (); System.out.print(" GetReportCountResponse");
System.out.println();
if (response.isSetGetReportCountResult()) {
System.out.print(" GetReportCountResult");
System.out.println();
GetReportCountResult getReportCountResult = response.getGetReportCountResult();
if (getReportCountResult.isSetCount()) {
System.out.print(" Count");
System.out.println();
System.out.print(" " + getReportCountResult.getCount());
System.out.println();
}
}
if (response.isSetResponseMetadata()) {
System.out.print(" ResponseMetadata");
System.out.println();
ResponseMetadata responseMetadata = response.getResponseMetadata();
if (responseMetadata.isSetRequestId()) {
System.out.print(" RequestId");
System.out.println();
System.out.print(" " + responseMetadata.getRequestId());
System.out.println();
}
}
System.out.println();
System.out.println(response.getResponseHeaderMetadata());
System.out.println(); } catch (MarketplaceWebServiceException ex) { System.out.println("Caught Exception: " + ex.getMessage());
System.out.println("Response Status Code: " + ex.getStatusCode());
System.out.println("Error Code: " + ex.getErrorCode());
System.out.println("Error Type: " + ex.getErrorType());
System.out.println("Request ID: " + ex.getRequestId());
System.out.print("XML: " + ex.getXML());
System.out.println("ResponseHeaderMetadata: " + ex.getResponseHeaderMetadata());
}
} }

  跑完控制台输出成功日志:

GetReportCount Action Response
============================================================================= GetReportCountResponse
GetReportCountResult
Count
1593
ResponseMetadata
RequestId
ae847abb-6335-4ec3-904c-b3fdbd999979 requestId : ae847abb-6335-4ec3-904c-b3fdbd999979
responseContext : bu7253H8xUoTt/yMP7gsP5osYa5dLIQ0Av+i7ENQwKBd14/ZhdEIw6yQW+2kan0HwujlUmeuaR8=
timestamp : 2018-07-16T07:57:35.453Z

亚马逊MWS开发套路演示的更多相关文章

  1. 亚马逊 MWS 开发者指南 漏桶算法

    流量控制与令牌桶算法|James Pan's Blog  https://blog.jamespan.me/2015/10/19/traffic-shaping-with-token-bucket 服 ...

  2. 亚马逊开放机器学习系统源代码:挑战谷歌TensorFlow

    北京时间5月17日上午消息,亚马逊在开源技术领域迈出了更大的步伐,宣布开放该公司的机器学习软件DSSTNE的源代码.这个最新项目将与谷歌的TensorFlow竞争,后者已于去年开源.亚马逊表示,在缺乏 ...

  3. HTML5游戏开发进阶指南(亚马逊5星畅销书,教你用HTML5和JavaScript构建游戏!)

    HTML5游戏开发进阶指南(亚马逊星畅销书,教你用HTML5和JavaScript构建游戏!) [印]香卡(Shankar,A.R.)著 谢光磊译 ISBN 978-7-121-21226-0 201 ...

  4. python 脚本开发实战-当当亚马逊图书采集器转淘宝数据包

    开发环境python2.7.9 os:win-xp exe打包工具pyinstaller 界面tkinter ============================================= ...

  5. Node开发文件上传系统及向七牛云存储和亚马逊AWS S3的文件上传

    背景起,有奏乐: 有伟人曰:学习技能的最好途径莫过于理论与实践相结合. 初学Node这货时,每每读教程必会Fall asleep. 当真要开发系统时,顿觉精神百倍,即便踩坑无数也不失斗志. 因为同团队 ...

  6. 使用AWS亚马逊云搭建Gmail转发服务(三)

    title: 使用AWS亚马逊云搭建Gmail转发服务(三) author:青南 date: 2015-01-02 15:42:22 categories: [Python] tags: [log,G ...

  7. 借助亚马逊S3和RapidMiner将机器学习应用到文本挖掘

    本挖掘典型地运用了机器学习技术,例如聚类,分类,关联规则,和预测建模.这些技术揭示潜在内容中的意义和关系.文本发掘应用于诸如竞争情报,生命科学,客户呼声,媒体和出版,法律和税收,法律实施,情感分析和趋 ...

  8. (转)来自互联网巨头的46个用户体验面试问题(谷歌,亚马逊,facebook及微软)

    原文出处: uxdesign - Eleonora Zucconi   译文出处:UXRen - 邓俊杰 如果你是个正在找工作的用户体验研究员,或是一个招聘经理正急需一些启发性问题来测试你的候选人,这 ...

  9. 亚马逊云科技现身世界人工智能大会,揭示AI最新技术趋势

    2022世界人工智能大会(WAIC)于日前落幕.经过过去四届的发展与沉淀,今天的世界人工智能大会已成为人工智能领域最有影响力的国际盛会之一,今年大咖云集.国际大厂扎堆,充分彰显了大会的国际影响力和磁力 ...

随机推荐

  1. 你真的会使用Chrome开发者工具吗?

    Chrome开发工具是一个Web开发者的利器,使用它你可以实现: 管理界面元素 断点调试JavaScript代码 优化你的代码 这里将列出一些非常实用的使用技巧,帮助你更加高效的工作 1. 快速编辑H ...

  2. vue中element 的上传功能

    element 的上传功能 最近有个需求,需要在上传文件前,可以进行弹窗控制是否上传upload 看完文档后,感觉有两种思路可以实现 基于before-upload :上传文件之前的钩子,参数为上传的 ...

  3. 二十二、utl_inaddr(用于取得局域网或Internet环境中的主机名和IP地址)

    1.概述 作用:用于取得局域网或Internet环境中的主机名和IP地址. 2.包的组成 1).get_host_name作用:用于取得指定IP地址所对应的主机名语法:utl_inaddr.get_h ...

  4. Windows消息队列(优先队列,结构体中放比较函数)

    Windows消息队列 消息队列是Windows系统的基础.对于每个进程,系统维护一个消息队列.如果在进程中有特定事件发生,如点击鼠标.文字改变等,系统将把这个消息加到队列当中.同时,如果队列不是空的 ...

  5. *SCM-MANAGER独立部署方式

    从官网获取最新版本 scm-manager 独立安装包 https://www.scm-manager.org/download/ 解压 为合适的路径 修改 services.bat 文件服务相关信息 ...

  6. QT出现 Cannot create children for a parent that is in a different thread 的解决方法:

    timer = new Timer(this);改成 timer = new Timer();就可以了. 因为你timer是属于主线程的,尽量不要在非主线程里创建新的对象并指定其对象为主线程内的对象, ...

  7. Android 仿微信朋友圈查看

    项目要做一个类似于这样的功能,就做了. 项目下载地址:http://download.csdn.net/detail/u014608640/9917626 一,看下效果: 二.activity类 pu ...

  8. HBase数据存储

    HRegionServer  HBase的数据文件都存储在HDFS上,格式主要有两种: - HFile:HBase中KeyValue数据的存储格式,HFile是Hadoop的二进制文件,实际上Sto ...

  9. python中封装

    封装 引子 从封装的本身意思去理解,封装就是用一个袋子,把买的水果.书.水杯一起装进袋子里,然后再把袋子的口给封上,照这样的理解来说,封装=隐藏,但是,这种理解是片面的 ## 如何封装 在python ...

  10. topcoder WCNMLGB

    点开题->断开连接->再也上不去->我玩NM