亚马逊调用Report接口全流程

论坛 期权论坛     
选择匿名的用户   2021-6-2 17:50   150   0
<p>亚马逊接口测试地址:</p>
<p><a href="https://mws.amazonservices.com/scratchpad/index.html">https://mws.amazonservices.com/scratchpad/index.html</a></p>
<p>开始 test </p>
<p><strong>AmazonApplicationTests</strong></p>
<pre class="blockcode"><code class="language-java">package com.example.amazon.amazon;

import com.example.amazon.amazon.untils.AmazonConstant;
import com.example.amazon.amazon.untils.AmazonUntil;
import com.example.amazon.amazon.untils.GetReportListUntil;
import com.example.amazon.amazon.untils.GetReportList;
import net.sf.json.JSONArray;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import java.math.BigDecimal;
import java.util.HashMap;

&#64;SpringBootApplication
&#64;RunWith(SpringRunner.class)
&#64;SpringBootTest
public class AmazonApplicationTests implements AmazonConstant {
/**
  *
  *AmazonUntil
  *Reports
  */
    &#64;Test
    public void Reports() {


        //***亚马逊提供密钥***
        String secretKey &#61; &#34;r1LaemH2Jx2x******************k2&#34;;
        HashMap&lt;String, String&gt; parameters &#61; new HashMap&lt;&gt;();
        //***亚马逊提供访问id***
        parameters.put(&#34;AWSAccessKeyId&#34;, AmazonUntil.urlEncode(&#34;AK*******KA&#34;));
        //***商家提供授权token***
        parameters.put(&#34;MWSAuthToken&#34;, AmazonUntil.urlEncode(&#34;amzn.mws.96**********b6&#34;));
        //***商家提供卖家id***
        parameters.put(&#34;SellerId&#34;, AmazonUntil.urlEncode(&#34;A1T**************IJGDS&#34;));
      
        //***Request URL: http://docs.developer.amazonservices.com/zh_CN/dev_guide/DG_Endpoints.html***
     parameters.put(&#34;ReportType&#34;, &#34;_GET_FBA_FULFILLMENT_CURRENT_INVENTORY_DATA_&#34;);
     parameters.put(&#34;MarketplaceId.Id.1&#34;, &#34;ATVPDKIKX0DER&#34;);
   
        try {
            String  orders &#61; AmazonUntil.doPost( parameters, secretKey);
          GetReportList(orders);
        } catch (Exception e) {
            ;
        }

      
        
        //todo 解析orders数组就是每一条订单的数据




    }
    /**
  *
  *GetReportListUntil
  *GetReportRequestList
  */
  
   public void GetReportList(String  ReportRequestId) {


       //***亚马逊提供密钥***
       String secretKey &#61; &#34;r1LaemH2Jx2xGStbTqadn1mVJwzYFLyBMKZQLKk2&#34;;
       HashMap&lt;String, String&gt; parameters &#61; new HashMap&lt;&gt;();
       //***亚马逊提供访问id***
       parameters.put(&#34;AWSAccessKeyId&#34;, AmazonUntil.urlEncode(&#34;AKIAJEBONJNSXN5L5WKA&#34;));
       //***商家提供授权token***
       parameters.put(&#34;MWSAuthToken&#34;, AmazonUntil.urlEncode(&#34;amzn.mws.96b29db4-0820-7d35-139c-ad9f3ea196b6&#34;));
       //***商家提供卖家id***
       parameters.put(&#34;SellerId&#34;, AmazonUntil.urlEncode(&#34;A1TUEZAEMIJGDS&#34;));
       //***Request URL: http://docs.developer.amazonservices.com/zh_CN/dev_guide/DG_Endpoints.html***
   
     //n为毫秒数
    try { Thread.sleep ( 10000 ) ;
    } catch (InterruptedException ie){}



       parameters.put(&#34;ReportRequestIdList.Id.1&#34;, ReportRequestId);
       String orders &#61; &#34;&#34;;
       try {
      
           orders &#61; GetReportListUntil.doPost( parameters, secretKey);
          System.out.println(&#34;?????&#34;&#43;orders);
         GetReport(orders);
           
       } catch (Exception e) {
           ;
       }

      
      
       //todo 解析orders数组就是每一条订单的数据




   }
   /**
   *
   *GetReportListUntil
   *GetReportList
   *  public void GetReport(String  GetReport) {
   */
  //  &#64;Test
   public void GetReport(String  GetReport) {


        //***亚马逊提供密钥***
        String secretKey &#61; &#34;r1LaemH2Jx2xGStbTqadn1mVJwzYFLyBMKZQLKk2&#34;;
        HashMap&lt;String, String&gt; parameters &#61; new HashMap&lt;&gt;();
        //***亚马逊提供访问id***
        parameters.put(&#34;AWSAccessKeyId&#34;, AmazonUntil.urlEncode(&#34;AKIAJEBONJNSXN5L5WKA&#34;));
        //***商家提供授权token***
        parameters.put(&#34;MWSAuthToken&#34;, AmazonUntil.urlEncode(&#34;amzn.mws.96b29db4-0820-7d35-139c-ad9f3ea196b6&#34;));
        //***商家提供卖家id***
        parameters.put(&#34;SellerId&#34;, AmazonUntil.urlEncode(&#34;A1TUEZAEMIJGDS&#34;));
        //***Request URL: http://docs.developer.amazonservices.com/zh_CN/dev_guide/DG_Endpoints.html***
     
        parameters.put(&#34;ReportId&#34;, GetReport);
        String orders &#61; &#34;&#34;;
        try {
            orders &#61; GetReportList.doPost( parameters, secretKey);
        } catch (Exception e) {
            ;
        }

      
        
        //todo 解析orders数组就是每一条订单的数据




    }

}</code></pre>
<p>2、RequestReport 接口调用</p>
<pre class="blockcode"><code class="language-java">package com.example.amazon.amazon.untils;


import net.sf.json.JSON;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import net.sf.json.xml.XMLSerializer;
import org.apache.commons.codec.binary.Base64;
import org.apache.http.HttpEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
impor
分享到 :
0 人收藏
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

积分:3875789
帖子:775174
精华:0
期权论坛 期权论坛
发布
内容

下载期权论坛手机APP