我是亚马逊 FBA 卖家,我想开始使用亚马逊 MWS 以更自动化的流程上传有关我的销售的数据。我刚刚创建了一个亚马逊 MWS 帐户并收到了不同的 ID(访问密钥 ID、秘密访问密钥……)。
我的印象是大多数 MWS 开发人员使用 C#。我有很多 Excel VBA 经验,但不是 C#。因此,我不确定必须遵循的步骤。
在下面的网页上,您可以找到我想要运行的 C# 代码:
http://www.samswiches.com/2011/02/how-to-use-amazon-mws-to-download-unshipped-order-reports/
你能确认以下步骤是正确的吗? :
1) 下载 Visual Studio => 我需要从亚马逊下载任何额外的包吗?
2) 在 Visual Studio 中:文件 => 新建项目 => C# 控制台应用程序
3) 擦除所有代码并将其替换为上面网站上找到的代码的复制粘贴 => 我是否需要将代码放入 VBA 中的“Sub - end Sub”之类的东西中?
4) 通过我的 ID 更改“YourSecretKey”、“YourSecretAccessKey”、“YourSecretAccessKey”、“YourMerchantID”、“YourMarketplaceID”。
5)点击运行按钮
如果有效,输出会是怎样的:Visual Studio 中的一个数组?文本文件?一个 csv 文件?它将存储在哪里?
我意识到这是一个非常新手的问题。但是,我认为一旦我的第一个代码正确运行,我的 VBA 经验将使我能够从那里高效地开始。
提前致谢,
迭戈。
查看代码后http://www.samswiches.com/2011/02/how-to-use-amazon-mws-to-download-unshipped-order-reports/ 我尝试并改变了一些东西,它起作用了。这是我的解决方案:
这是代码。
using System;
using System.Xml.Serialization;
using System.Collections.Generic;
using MarketplaceWebService;
using MarketplaceWebService.Mock;
using MarketplaceWebService.Model;
using System.IO;
using System.Threading;
public void testReport()
{
String accessKeyId = "Your Access Key ID";
String secretAccessKey = "Your Secret Access Key";
const string merchantId = "Merchant ID";
const string marketplaceId = "Marketplace ID";
MarketplaceWebServiceConfig config = new MarketplaceWebServiceConfig();
config.ServiceURL = "https://mws.amazonservices.com";
const string applicationName = "ApplicationName";
const string applicationVersion = "0.01";
MarketplaceWebServiceClient service =
new MarketplaceWebServiceClient(
accessKeyId,
secretAccessKey,
applicationName,
applicationVersion,
config);
RequestReportRequest reportRequestRequest = new RequestReportRequest();
reportRequestRequest.Merchant = merchantId;
// you can change ReportType here:
//http://docs.developer.amazonservices.com/en_IN/reports/Reports_ReportType.html
reportRequestRequest.ReportType = “_GET_FLAT_FILE_ACTIONABLE_ORDER_DATA_";
RequestReportResponse requestResponse = service.RequestReport(reportRequestRequest);
IdList lstRequestID = new IdList();
lstRequestID.Id.Add
(requestResponse.RequestReportResult.ReportRequestInfo.ReportRequestId);
GetReportRequestListRequest reportRequestListRequest = new
GetReportRequestListRequest();
reportRequestListRequest.Merchant = merchantId;
reportRequestListRequest.ReportRequestIdList = lstRequestID;
List<ReportRequestInfo> myListzz = new List<ReportRequestInfo>();
GetReportRequestListResponse reportRequestListResponse = new
GetReportRequestListResponse();
reportRequestListResponse =
service.GetReportRequestList(reportRequestListRequest);
GetReportRequestListResult reportRequestListResult = new
GetReportRequestListResult();
reportRequestListResult =
reportRequestListResponse.GetReportRequestListResult;
myListzz = reportRequestListResult.ReportRequestInfo;
if (myListzz.Count > 0)
{
while (myListzz[0].ReportProcessingStatus.ToString() != "_DONE_")
{
Console.WriteLine("Waiting for Report");
Thread.Sleep(61000);
reportRequestListResponse =
service.GetReportRequestList(reportRequestListRequest);
reportRequestListResult =
reportRequestListResponse.GetReportRequestListResult;
myListzz = reportRequestListResult.ReportRequestInfo;
}
if (myListzz[0].GeneratedReportId !=null)
{
GetReportRequest reportRequest = new GetReportRequest();
reportRequest.Merchant = merchantId;
String source = "C:\\myreport.txt";
reportRequest.ReportId = myListzz[0].GeneratedReportId;
reportRequest.Report = File.Open(source, FileMode.Create,
FileAccess.ReadWrite);
service.GetReport(reportRequest);
}
}
}
您缺少步骤 1b) 下载 C# MWS 报告 API 客户端库。您可能需要其他库来访问 MWS API 的其他部分,但快速浏览一下上面的代码库是主要的。
请注意,它指的是一个
lblStatus
,它似乎是表格上的标签,但在那篇文章中没有任何地方提到该表格。所以步骤 2) 可能不是一个“控制台”样式的应用程序,而是一个基于表单的应用程序,这也意味着,您不应该删除步骤 3 中的所有代码,而是将代码粘贴到与 main() 函数等效的任何地方(我只用过C和C++,没用过C#,所以不知道)