2017-05-16 4 views
0

私はアマゾンのスクラッチパッドからコードを取得しており、パッケージが必要です。 SignedRequestHelperクラスはパッケージに含まれていないため、プログラムを実行できません。私はアマゾンasin番号を使用してアイテムの価格を取得しようとしています。Amazon広告API:SignedRequestHelperクラスが見つかりません

package com.amazon.advertising.api.sample; 

import java.util.HashMap; 
import java.util.Map; 

import javax.xml.parsers.DocumentBuilder; 
import javax.xml.parsers.DocumentBuilderFactory; 

import org.w3c.dom.Document; 
import org.w3c.dom.Node; 

/* 
* This class shows how to make a simple authenticated call to the 
* Amazon Product Advertising API. 
* 
* See the README.html that came with this sample for instructions on 
* configuring and running the sample. 
*/ 
public class lookup { 

    /* 
    * Your AWS Access Key ID, as taken from the AWS Your Account page. 
    */ 
    private static final String AWS_ACCESS_KEY_ID = "XXXXXX"; 

    /* 
    * Your AWS Secret Key corresponding to the above ID, as taken from the AWS 
    * Your Account page. 
    */ 
    private static final String AWS_SECRET_KEY = "XXXXXXX"; 

    /* 
    * Use the end-point according to the region you are interested in. 
    */ 
    private static final String ENDPOINT = "webservices.amazon.com"; 


    public static void main(String[] args) { 

     /* 
     * Set up the signed requests helper. 
     */ 
     SignedRequestsHelper helper; 

     try { 
     } catch (Exception e) { 
      e.printStackTrace(); 
      return; 
     } 

     String requestUrl = null; 

     Map<String, String> params = new HashMap<String, String>(); 

     params.put("Service", "AWSECommerceService"); 
     params.put("Operation", "ItemLookup"); 
     params.put("AWSAccessKeyId", "XXXXXX"); 
     params.put("AssociateTag", "XXXXX"); 
     params.put("ItemId", "B01H57GXUQ"); 
     params.put("IdType", "ASIN"); 
     params.put("ResponseGroup", "Images,ItemAttributes,Offers"); 

     requestUrl = helper.sign(params); 

     System.out.println("Signed URL: \"" + requestUrl + "\""); 
    } 
} 

どのようにすれば、私はsignedrequestshelperメソッドを取得できますか?コードをどのように変更できますか?あなたはコピー/それは実行して動作させるために、プロジェクトにコードを貼り付けることができ

http://docs.aws.amazon.com/AWSECommerceService/latest/DG/AuthJavaSampleSig2.html

答えて

0

SignedRequestHelperは、ここではAWSからのコードサンプルのいずれかで使用可能なクラスです。

+1

また、これらの3つのエラーが発生しており、お手伝いできるかどうか疑問に思っていました。ありがとうございましたエラー:未報告の例外UnsupportedEncodingException;キャッチまたは宣言されている必要があります バイト[] secretyKeyBytes = awsSecretKey.getBytes(UTF8_CHARSET); エラー:報告されない例外NoSuchAlgorithmException;キャッチされるか、スローされると宣言されなければならない。 mac = Mac.getInstance(HMAC_SHA256_ALGORITHM); エラー:報告されない例外InvalidKeyException;キャッチされるか、またはスローされると宣言されなければならない。 mac.init(secretKeySpec); – Max01

関連する問題