热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

亚马逊MWS开发套路演示

MWS是商城网络服务的缩写,具体介绍看这里http:docs.developer.amazonservices.comzh_CNdev_guideDG_IfNew.h

  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.************************************************************************/// USconfig.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 = "";GetReportCountRequest request = new GetReportCountRequest();request.setMerchant( merchantId );//request.setMWSAuthToken(sellerDevAuthToken);// @TODO: set request parameters hereinvokeGetReportCount(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
=============================================================================GetReportCountResponseGetReportCountResultCount1593ResponseMetadataRequestIdae847abb-6335-4ec3-904c-b3fdbd999979requestId : ae847abb-6335-4ec3-904c-b3fdbd999979
responseContext : bu7253H8xUoTt/yMP7gsP5osYa5dLIQ0Av+i7ENQwKBd14/ZhdEIw6yQW+2kan0HwujlUmeuaR8=
timestamp : 2018-07-16T07:57:35.453Z



推荐阅读
  • 表达式树摘录(1)
    本文主要讲述ConstantExpression介绍表示具有常量值的表达式。ParameterExpression介绍表示命名的参数表达式。UnaryExpression介绍表示包 ... [详细]
  • 微软头条实习生分享深度学习自学指南
    本文介绍了一位微软头条实习生自学深度学习的经验分享,包括学习资源推荐、重要基础知识的学习要点等。作者强调了学好Python和数学基础的重要性,并提供了一些建议。 ... [详细]
  • 阿里Treebased Deep Match(TDM) 学习笔记及技术发展回顾
    本文介绍了阿里Treebased Deep Match(TDM)的学习笔记,同时回顾了工业界技术发展的几代演进。从基于统计的启发式规则方法到基于内积模型的向量检索方法,再到引入复杂深度学习模型的下一代匹配技术。文章详细解释了基于统计的启发式规则方法和基于内积模型的向量检索方法的原理和应用,并介绍了TDM的背景和优势。最后,文章提到了向量距离和基于向量聚类的索引结构对于加速匹配效率的作用。本文对于理解TDM的学习过程和了解匹配技术的发展具有重要意义。 ... [详细]
  • EPICS Archiver Appliance存储waveform记录的尝试及资源需求分析
    本文介绍了EPICS Archiver Appliance存储waveform记录的尝试过程,并分析了其所需的资源容量。通过解决错误提示和调整内存大小,成功存储了波形数据。然后,讨论了储存环逐束团信号的意义,以及通过记录多圈的束团信号进行参数分析的可能性。波形数据的存储需求巨大,每天需要近250G,一年需要90T。然而,储存环逐束团信号具有重要意义,可以揭示出每个束团的纵向振荡频率和模式。 ... [详细]
  • 原文地址:https:www.cnblogs.combaoyipSpringBoot_YML.html1.在springboot中,有两种配置文件,一种 ... [详细]
  • ZSI.generate.Wsdl2PythonError: unsupported local simpleType restriction ... [详细]
  • 推荐系统遇上深度学习(十七)详解推荐系统中的常用评测指标
    原创:石晓文小小挖掘机2018-06-18笔者是一个痴迷于挖掘数据中的价值的学习人,希望在平日的工作学习中,挖掘数据的价值, ... [详细]
  • 本文详细介绍了MySQL表分区的创建、增加和删除方法,包括查看分区数据量和全库数据量的方法。欢迎大家阅读并给予点评。 ... [详细]
  • centos安装Mysql的方法及步骤详解
    本文介绍了centos安装Mysql的两种方式:rpm方式和绿色方式安装,详细介绍了安装所需的软件包以及安装过程中的注意事项,包括检查是否安装成功的方法。通过本文,读者可以了解到在centos系统上如何正确安装Mysql。 ... [详细]
  • 本文介绍了在开发Android新闻App时,搭建本地服务器的步骤。通过使用XAMPP软件,可以一键式搭建起开发环境,包括Apache、MySQL、PHP、PERL。在本地服务器上新建数据库和表,并设置相应的属性。最后,给出了创建new表的SQL语句。这个教程适合初学者参考。 ... [详细]
  • 本文介绍了数据库的存储结构及其重要性,强调了关系数据库范例中将逻辑存储与物理存储分开的必要性。通过逻辑结构和物理结构的分离,可以实现对物理存储的重新组织和数据库的迁移,而应用程序不会察觉到任何更改。文章还展示了Oracle数据库的逻辑结构和物理结构,并介绍了表空间的概念和作用。 ... [详细]
  • 目录实现效果:实现环境实现方法一:基本思路主要代码JavaScript代码总结方法二主要代码总结方法三基本思路主要代码JavaScriptHTML总结实 ... [详细]
  • 本文介绍了九度OnlineJudge中的1002题目“Grading”的解决方法。该题目要求设计一个公平的评分过程,将每个考题分配给3个独立的专家,如果他们的评分不一致,则需要请一位裁判做出最终决定。文章详细描述了评分规则,并给出了解决该问题的程序。 ... [详细]
  • sklearn数据集库中的常用数据集类型介绍
    本文介绍了sklearn数据集库中常用的数据集类型,包括玩具数据集和样本生成器。其中详细介绍了波士顿房价数据集,包含了波士顿506处房屋的13种不同特征以及房屋价格,适用于回归任务。 ... [详细]
  • 荐
                                                        应用程序负载均衡器概述
    关注公众号:AWS爱好者(iloveaws)文|沉默恶魔(禁止转载,转载请先经过作者同意)网站:www.iloveaws.cnHello大家好,欢迎来到《AWS解决方案架构师 ... [详细]
author-avatar
山尖的霞1820_946
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有