【问题标题】:C# - First step with Amazon MWSC# - 亚马逊 MWS 的第一步
【发布时间】:2017-07-14 10:27:39
【问题描述】:

我是亚马逊 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 经验将使我能够从那里高效地开始。

提前致谢,

迭戈。

【问题讨论】:

    标签: c# amazon amazon-mws


    【解决方案1】:

    查看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);
                }
            }
      }
    

    【讨论】:

      【解决方案2】:

      您缺少步骤 1b) 下载 C# MWS Reports API Client Library。您可能需要其他库来访问 MWS API 的其他部分,但快速浏览一下上面的代码库是主要的。

      请注意,它指的是lblStatus,这似乎是表单上的一个标签,但在那篇文章中没有任何地方提到该表单。所以步骤 2) 可能不是“控制台”风格的应用程序,而是基于表单的应用程序,这也意味着,您不应该删除步骤 3 中的所有代码,而是将代码粘贴到与 main() 函数等效的任何内容中(我只用过C和C++,没用过C#,所以不知道)

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2011-11-13
        • 2012-02-12
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多