0

I have got code from amazon scratchpad and got the package required. The SignedRequestHelper class is not in the package and i am unable to run the program. I am attempting to get the price of the item using the amazon asin number.

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 + "\"");
    }
}

How would i be able to get the signedrequestshelper method or how would i be able to change the code?

John Rotenstein
  • 241,921
  • 22
  • 380
  • 470
Max01
  • 1
  • 2

1 Answers1

0

SignedRequestHelper is a class available in one of the code samples from AWS here:

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

You can copy/paste the code in your project to make it run and work.

Yeshodhan Kulkarni
  • 2,844
  • 1
  • 16
  • 19
  • 1
    I am also getting these three errors and was wondering if you would be able to help. Thank you error: unreported exception UnsupportedEncodingException; must be caught or declared to be thrown byte[] secretyKeyBytes = awsSecretKey.getBytes(UTF8_CHARSET); error: unreported exception NoSuchAlgorithmException; must be caught or declared to be thrown mac = Mac.getInstance(HMAC_SHA256_ALGORITHM); error: unreported exception InvalidKeyException; must be caught or declared to be thrown mac.init(secretKeySpec); – Max01 May 18 '17 at 02:11