vendredi 29 mai 2015

Querying Amazon product search API in Cloud Code

I would like to perform a product search on Amazon from Cloud Code. Looking around the web I have found only this snippet (on Reddit):

console.log('about to define AmazonHttpRequestPromise');

    var AmazonHttpRequestPromise = Parse.Cloud.httpRequest({
        url: url,
        params: {
          'AWSAccessKeyId': '*ACCESS KEY GOES HERE*',
          'AssociateTag': '*ASSOCIATE TAG GOES HERE*',
          'Keywords': 'harry+potter',
          'Operation': 'ItemSearch',
          'SearchIndex': 'Books',
          'Service': 'AWSECommerceService',
          'Version': '2013-08-01',
        }
      });

    console.log('AmazonHttpRequestPromise looks like this:' + AmazonHttpRequestPromise);

    return AmazonHttpRequestPromise;

    function (err) {
      console.log('error!' + err);
      response.error('DAMN IT MAN');
    }

Questions:

1) Is this the best approach?

2) Do I need any special permission from Amazon for performing this operation and showing my user the results?




Aucun commentaire:

Enregistrer un commentaire