GithubHelp home page GithubHelp logo

exeu / apai-io Goto Github PK

View Code? Open in Web Editor NEW
629.0 59.0 156.0 441 KB

DISCONTINUED Amazon Product Adverstising Library based on PHP REST and SOAP (only V1) using the Product Advertising API.

Home Page: http://apai-io.readthedocs.io/en/latest/

PHP 100.00%
amazon php product advertising api rest aws

apai-io's Introduction

DISCONTINUED

If you want to implement new features you can still fork and enhance this repo. Please let me know if you plan to enhance this library then i can add your fork to this list.

apai-io

Scrutinizer Code Quality Code Coverage Build Status Latest Stable Version Total Downloads Build Status Documentation Status

ApaiIO is a highly flexible PHP library for fetching the Product Advertising API using REST or SOAP. You can either use the built in operations like ItemSearch or ItemLookup or you can implement your own operations which fits to your needs.

Everything is programmed against interfaces so you can implement your own request or response classes for example.

This class is realized by the Product Advertising API (former ECS) from Amazon WS Front. https://affiliate-program.amazon.com/gp/advertising/api/detail/main.html

Documentation

The documentation is currently under construction.

You can read here: http://apai-io.readthedocs.io/en/latest/

Installation

Composer

$ composer require exeu/apai-io

Composer will generate the autoloader file automaticaly. So you only have to include this. Typically its located in the vendor dir and its called autoload.php

Basic Usage:

This library is using the PSR-4 standard: https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-4-autoloader.md So you can use any autoloader which fits into this standard. The tests directory contains an example bootstrap file.

<?php
namespace Acme\Demo;

use ApaiIO\Configuration\GenericConfiguration;
use ApaiIO\Operations\Search;
use ApaiIO\ApaiIO;

$conf = new GenericConfiguration();
$client = new \GuzzleHttp\Client();
$request = new \ApaiIO\Request\GuzzleRequest($client);

$conf
    ->setCountry('com')
    ->setAccessKey(AWS_API_KEY)
    ->setSecretKey(AWS_API_SECRET_KEY)
    ->setAssociateTag(AWS_ASSOCIATE_TAG)
    ->setRequest($request);
$apaiIO = new ApaiIO($conf);

$search = new Search();
$search->setCategory('DVD');
$search->setActor('Bruce Willis');
$search->setKeywords('Die Hard');

$formattedResponse = $apaiIO->runOperation($search);

var_dump($formattedResponse);

For some very simple examples go to the samples-folder and have a look at the sample files. These files contain all information you need for building queries successful.

Webservice Documentation:

Hosted on Amazon.com: http://docs.amazonwebservices.com/AWSECommerceService/latest/DG/

apai-io's People

Contributors

apzentral avatar badalsurana avatar benmorel avatar bryant1410 avatar cschalenborgh avatar cyrrill avatar dafish avatar dmaslov avatar dspasic avatar exeu avatar hareku avatar lemmingz avatar napolux avatar nikola-barac avatar nyholm avatar pocketrocket avatar remo avatar samnela avatar schmiddim avatar scottrobertson avatar tobeorla avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

apai-io's Issues

Fatal error: Uncaught SoapFault exception: [aws:Client.RequestThrottled]

Hey!

My app was working very good for some days but yesterday my app throwed the following error:

Fatal error: Uncaught SoapFault exception: [aws:Client.RequestThrottled] Request from A1PAQS5FGRGV1 is throttled.

I updated my obsolete ApaIO class with the new commit from github but error still appears.

What is happening?

Regards!

Add support for parallel requests

Using e.g. curl_multi() it is possible to do HTTP requests in parallel. This technique would decrease the loading time in situations where more than one requests need to be done. This makes also a lot of sense when retrieving information from APIs.

Parallel requests could for example be used to obtain results from the german and the british catalog in parallel. This would be a really nice feature and add a noticable speed bump.

No results returned

Hi,

Thanks for developing this library. I'm trying to search an item and although amazon search reveals results, but the API doesn't.

$search = new Search();
$search->setResponseGroup(array('ItemAttributes','ItemIds','Large'));
//$search->setCategory('All');
$search->setBrand('STARTECH'); 
$search->setKeywords('HDMI to VGA Adapter Converter 1920x1080');
$search->setCondition('New');
$search->setMinimumPrice('36.982'); 

.... there're no errors either so the query is correct. But as you can see here: http://www.amazon.com/s/ref=sr_nr_p_89_0?fst=as%3Aoff&rh=i%3Aaps%2Ck%3AHDMI+to+VGA+Adapter+Converter+1920x1080%2Cp_89%3AStarTech&keywords=HDMI+to+VGA+Adapter+Converter+1920x1080&ie=UTF8&qid=1424846004&rnid=2528832011 it should return results.

Setting category to all and remove brand shows results though. I tried the case sensitive brand name also, but still no results.

Item Parameters not Passed to API for CartCreate and CartAdd when using SOAP

With both CartCreate and CartAdd, if communicating with the API through SOAP, the item parameters don't get passed to the API.

Error Code is AWS.MissingParameters.
Error Message is "Your request is missing required parameters. Required parameters include Items."

If, on the other hand, we use REST, the item parameters get passed, and this error does not occur.

SSL connection required for SOAP authentication

All was working fine, but suddenly Error "SSL connection required for SOAP authentication" arises. Is this some thing wrong with Amazon API Servers or I am missing something in client configuration?

Receiving multiplte countries

Receiving the data for one country (e.g. Amazon.de) will work with the following example. So far so good.

try {
    $conf
        ->setCountry('de')
        ->setAccessKey(AWS_API_KEY)
        ->setSecretKey(AWS_API_SECRET_KEY)
        ->setAssociateTag(AWS_ASSOCIATE_TAG);
} catch (\Exception $e) {
    echo $e->getMessage();
}
$apaiIO = new ApaiIO($conf);
$search = new Search();
$search->setCategory('DVD');
$search->setActor('Bruce Willis');
$search->setKeywords('Stirb Langsam');
$search->setPage(3);
$search->setResponseGroup(array('Large', 'Small'));
$formattedResponse = $apaiIO->runOperation($search);
echo $formattedResponse;

Is there a chance to get multiple country responses (e.g. for Amazon.com, Amazon.de & Amazon.es) within one api call? So in fact that I got the product links for each country store?

You are submitting requests too quickly. Please retry your requests at a slower rate

Hi Exeu,

I'm currently testing your library and it's working well, so - thanks.

But sometimes I receive the error "requests too quickly". I know this error comes from amazon but I have in mind, that there was somewere an option to slow this down by your lib. But I can't find it anymore.

Can you give me a hint?

Thanks and cheers,
Matthias

Throttling / Rate Limiting

I keep getting:

<b>Fatal error</b>:  Uncaught exception 'RuntimeException' with message 'An error occurred while     sending request. Error number: 28; Error message: Operation timed out after 10000 milliseconds with     5583 bytes received' in /vendor/exeu/apai-io/lib/ApaiIO/Request/Rest/Request.php:172
Stack trace:
#0 /vendor/exeu/apai-io/lib/ApaiIO/ApaiIO.php(73): ApaiIO\Request\Rest\Request-&gt;perform(Object(ApaiIO\Operations\Search))
#1 amazon.php(81): ApaiIO\ApaiIO-&gt;runOperation(Object(ApaiIO\Operations\Search))
#2 amazon.php(58): searchItem('INTERMEC', 'Hand Strap for ...', 35.442, 'com')
#3 combined.php(103): getItem('INTERMEC', 'Hand Strap for ...', 35.442, 'com')
#4 {main}
  thrown in <b>/vendor/exeu/apai-io/lib/ApaiIO/Request/Rest/Request.php</b> on line <b>172</b><br />

.. is there any way to rate limit the requests to 1 request / sec which is the current limit.

Kindl not supported?

Hello. I dont think this is a bug in apai-io, but maybe? I request a ASIN for a "kindl" item but response have no "OfferSummary" data. Is this my mistake, from amazon or a problem with apai-io? All products working fine with apai-io exclude kindl items for amazon.DE.

I want the price of this item: http://www.amazon.de/exec/obidos/ASIN/B00J50S1IY/

        $lookup = new Lookup();
        $lookup->setItemId(implode(',',$items));
        $lookup->setResponseGroup(array('Offers'));
        $apaiIo = new ApaiIO($conf);
        return $apaiIo->runOperation($lookup);

Result is:

<?xml version="1.0" ?><ItemLookupResponse xmlns="http://webservices.amazon.com/AWSECommerceService/2011-08-01"><OperationRequest><HTTPHeaders><Header Name="UserAgent" Value="ApaiIO [2.0.0-DEV]"></Header></HTTPHeaders><RequestId>*********</RequestId><Arguments><Argument Name="Operation" Value="ItemLookup"></Argument><Argument Name="Service" Value="AWSECommerceService"></Argument><Argument Name="Signature" Value="******"></Argument><Argument Name="AssociateTag" Value="**********"></Argument><Argument Name="Version" Value="2011-08-01"></Argument><Argument Name="ItemId" Value="B00J50S1IY"></Argument><Argument Name="AWSAccessKeyId" Value="********"></Argument><Argument Name="Timestamp" Value="2015-02-08T20:33:04Z"></Argument><Argument Name="ResponseGroup" Value="Offers"></Argument></Arguments><RequestProcessingTime>0.0129570000000000</RequestProcessingTime></OperationRequest><Items><Request><IsValid>True</IsValid><ItemLookupRequest><IdType>ASIN</IdType><ItemId>B00J50S1IY</ItemId><ResponseGroup>Offers</ResponseGroup><VariationPage>All</VariationPage></ItemLookupRequest></Request><Item><ASIN>B00J50S1IY</ASIN></Item></Items></ItemLookupResponse>

Here a example from another item with working result:

<?xml version="1.0" ?><ItemLookupResponse xmlns="http://webservices.amazon.com/AWSECommerceService/2011-08-01"><OperationRequest><HTTPHeaders><Header Name="UserAgent" Value="ApaiIO [2.0.0-DEV]"></Header></HTTPHeaders><RequestId>**********</RequestId><Arguments><Argument Name="Operation" Value="ItemLookup"></Argument><Argument Name="Service" Value="AWSECommerceService"></Argument><Argument Name="Signature" Value="**********"></Argument><Argument Name="AssociateTag" Value="**********"></Argument><Argument Name="Version" Value="2011-08-01"></Argument><Argument Name="ItemId" Value="B00PQ7E5VC"></Argument><Argument Name="AWSAccessKeyId" Value="**********"></Argument><Argument Name="Timestamp" Value="2015-02-08T20:41:53Z"></Argument><Argument Name="ResponseGroup" Value="Offers"></Argument></Arguments><RequestProcessingTime>0.0205450000000000</RequestProcessingTime></OperationRequest><Items><Request><IsValid>True</IsValid><ItemLookupRequest><IdType>ASIN</IdType><ItemId>B00PQ7E5VC</ItemId><ResponseGroup>Offers</ResponseGroup><VariationPage>All</VariationPage></ItemLookupRequest></Request><Item><ASIN>B00PQ7E5VC</ASIN><OfferSummary><LowestNewPrice><Amount>1299</Amount><CurrencyCode>EUR</CurrencyCode><FormattedPrice>EUR 12,99</FormattedPrice></LowestNewPrice><TotalNew>1</TotalNew><TotalUsed>0</TotalUsed><TotalCollectible>0</TotalCollectible><TotalRefurbished>0</TotalRefurbished></OfferSummary><Offers><TotalOffers>1</TotalOffers><TotalOfferPages>1</TotalOfferPages><MoreOffersUrl>**********</MoreOffersUrl><Offer><OfferAttributes><Condition>New</Condition></OfferAttributes><OfferListing><OfferListingId>**********</OfferListingId><Price><Amount>1299</Amount><CurrencyCode>EUR</CurrencyCode><FormattedPrice>EUR 12,99</FormattedPrice></Price><Availability>Noch nicht verรถffentlicht</Availability><AvailabilityAttributes><AvailabilityType>now</AvailabilityType><IsPreorder>1</IsPreorder><MinimumHours>48</MinimumHours><MaximumHours>72</MaximumHours></AvailabilityAttributes><IsEligibleForSuperSaverShipping>1</IsEligibleForSuperSaverShipping></OfferListing></Offer></Offers></Item></Items></ItemLookupResponse>"

Can anybody help here, please? :)

Shipping costs

Any suggestion how to receive the shipping costs of a product? Can't get the values so far

Advantage of Installing in the Way You Recommend?

I've gotten your sample code to work without installing your library in your recommended fashion. I just included all the libary files, in required order, in my PHP code, and I commented out the require_once of bootstrap.php. This avoided dealing with shared server management to get them to install the way you recommend.

What advantages would I have if I get it installed the way you recommend instead? And, what disadvantages do I have doing it the way I have?

Signature does not match

I try execute example from documentation:

...
$search = new Search();
$search->setCategory('DVD');
$search->setActor('Bruce Willis');
$search->setKeywords('Die Hard');
...

And get this:

string(427) "<?xml version="1.0"?>
<ItemSearchErrorResponse xmlns="http://ecs.amazonaws.com/doc/2011-08-01/"><Error><Code>SignatureDoesNotMatch</Code><Message>The request signature we calculated does not match the signature you provided. Check your AWS Secret Access Key and signing method. Consult the service documentation for details.</Message></Error><RequestId>21fc60ae-c9f1-4b2a-a0a5-366750ac4e86</RequestId></ItemSearchErrorResponse>"

Error getting data with SOAP

Hello. First of all, thank you for the great library.
I was successfully returning products for almost 6 months with no issues. Without changing any line of code, the PHP code stop working few days ago, see error message. Before the error message, I am putting pieces of my code. Thank you in advance.

    ->setResponseTransformer('\ApaiIO\ResponseTransformer\ObjectToArray')
    ->setRequest('\ApaiIO\Request\Soap\Request')
    ->setCountry('com')

$browseNodeLookup = new BrowseNodeLookup();
$browseNodeLookup->setNodeId('2619526011'); /*node number */
$browseNodeLookup->setResponseGroup(array('TopSellers', 'MostWishedFor'));
$formattedResponse = $apaiIO->runOperation($browseNodeLookup); 

if (array_key_exists("TopItemSet", $formattedResponse["BrowseNodes"]["BrowseNode"]))

The error is happening exactly in the last line above. The error message is below.

Fatal error: Uncaught SoapFault exception: [aws:Server.InternalError] We encountered an internal error. Please try again. in /home/storage/e/3d/de/site157/public_html/backend/data_reader/lib/ApaiIO/Request/Soap/Request.php:152 Stack trace: #0 /home/storage/e/3d/de/site157/public_html/backend/data_reader/lib/ApaiIO/Request/Soap/Request.php(152): SoapClient->__soapCall('BrowseNodeLooku...', Array) #1 /home/storage/e/3d/de/site157/public_html/backend/data_reader/lib/ApaiIO/Request/Soap/Request.php(67): ApaiIO\Request\Soap\Request->performSoapRequest(Object(ApaiIO\Operations\BrowseNodeLookup), Array) #2 /home/storage/e/3d/de/site157/public_html/backend/data_reader/lib/ApaiIO/ApaiIO.php(73): ApaiIO\Request\Soap\Request->perform(Object(ApaiIO\Operations\BrowseNodeLookup)) #3 /home/storage/e/3d/de/site157/public_html/backend/data_reader/reader_part_1.php(65): ApaiIO\ApaiIO->runOperation(Object(ApaiIO\Operations\BrowseNodeLookup)) #4 {main} thrown in /home/storage/e/3d/de/site157/public_html/backend/data_reader/lib/ApaiIO/Request/Soap/Request.php on line 152

Class 'ApaiIO\Configuration\GenericConfiguration' not found Error!

Hi guyz,

I have installed apai-io using composer in Laravel 5.

But when i try to run the below code. It give me error.

"Class 'ApaiIO\Configuration\GenericConfiguration' not found Error!"

AmazonAPI.php-

<?php

use ApaiIO\ApaiIO;
use ApaiIO\Configuration\GenericConfiguration;
use ApaiIO\Operations\Lookup;

$conf = new GenericConfiguration();
?>

safe_mode & open_basedir issue

Hi I have a client, that I implemented this for, that used shared hosting, when using this library I am getting the following errors:
Fatal error: Uncaught exception 'RuntimeException' with message 'An error occurred while setting 52 with value 1' in {omitted}/vendor/exeu/apai-io/lib/ApaiIO/Request/Rest/Request.php:143

i took a look at that file and the following code is there:

foreach ($options as $currentOption => $currentOptionValue) {
            if (false === @curl_setopt($ch, $currentOption, $currentOptionValue)) {
                throw new \RuntimeException(
                    sprintf(
                        "An error occurred while setting %s with value %s",
                        $currentOption,
                        $currentOptionValue
                    )
                );
            }
        }

after removing the @ and running again i see the following error:
Warning: curl_setopt(): CURLOPT_FOLLOWLOCATION cannot be activated when safe_mode is enabled or an open_basedir is set in {omitted}/vendor/exeu/apai-io/lib/ApaiIO/Request/Rest/Request.php on line 142

would there be a way to get round this?

Installation & Use without composer possible?

Is it possible to install and use this library without composer? In fact I want to integrate this into a plugin and the old fashion way with an include/require would be best in my opinion.

Thought about something like:

require_once "lib/ApaiIO/ApaiIO.php";

use ApaiIO\Configuration\GenericConfiguration;
use ApaiIO\ApaiIO;

$conf = new GenericConfiguration();

$conf
    ->setCountry('com')
    ->setAccessKey('YOUR ACCESS KEY')
    ->setSecretKey('YOUR SECRET KEY')
    ->setAssociateTag('YOUR ASSOCIATE TAG');

$apaiIo = new ApaiIO($conf);

SoapClient not found

Hi,

since the last update I got an Exception raised from the Request class saying that it can't found the SoapClient.

FatalErrorException: Error: Class 'SoapClient' not found in
/var/www/html/vendor/exeu/apai-io/lib/ApaiIO/Request/Soap/Request.php line 136

Could you tell us what has changed ? Thanks

Use callable arguments instead Closure in GenericConfigurationsetRequestFactory

The type hint here makes no sense, if we take a look in the ApaiIO\Request\RequestFactory::applyCallback method. The applyCallback method expects a callable argument and this is not only a closure. I would suggest to remove the type hint here and to validate the argument with the function is_callable. If the validation fails, we should throw a InvalidArgumentExeption. Since we support the php 5.3 version, we can't use the callable type hint. Rremove the type hint here and validate the argument with the function is_callable.

d1a1e64#commitcomment-4159922

Batch Requests?

Is there a way to use this framework to submit batch requests to the API?

I'm referring to what's documented in Amazon's Product Advertising API Developer Guide, starting page 71, Batch Requests (enabling 2 different requests to be sent simultaneously and responded to simultaneously).

It would enable REST requests, for example, to use

Operation.1.ParameterName=ParameterValue
Operation.2.ParameterName=ParameterValue
Operation.Shared.ParameterName=ParameterValue

This would enable getting 2 consecutive pages totaling 20 products, without waiting 1 second between requests. (I'd need it to work with SOAP requests, too.)

Add more request parameters for search

The search of products in the doc of amazon you can search for plenty of values:

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

I have modified the class to support BrowseNode and look into all the items of a category, just setting it in the Search class

/**
 * Sets the amazon browseNode
 *
 * @param string $browseNode
 *
 * @return \ApaiIO\Operations\Search
 */
public function setBrowseNode($browseNode)
{
    if (false === is_numeric($browseNode) || (int)$browseNode < 0) {
        throw new \InvalidArgumentException(
            sprintf(
                '%s is an invalid browseNode value. It has to be numeric and positive',
                $page
            )
        );
    }        

    $this->parameter['BrowseNode'] = $browseNode;

    return $this;
}

isn't a good idea to add all it? so far as it has setCondition and minimumPrice...

If it's ok I can make a pull request of the change.

Root Acces Keys vs. IAM User Access Keys

I guess this is not a native apai-io problem but so far I have not been able to use user access keys as they are recommended by amazon:

Delete your AWS root account access keys, because they provide unrestricted access to your AWS resources. Instead, use IAM user access keys or temporary security credentials.

If I use my root access keys everything is fine. If I use the user access keys I have created for my project, I get this message instead:

...AWS.InvalidAccount Your AccessKey Id is not registered for Product Advertising API. Please use the AccessKey Id obtained after registering at https://affiliate-program.amazon.com/gp/flex/advertising/api/sign-in.html.

My guess is that I need additional settings for groups/roles/policies for this particular user but I'm lost what exactly is expected my AWN.

If anybody could shed some light, I would be very happy.

Cheers,

pepebe

Other locales?

I see the demo only has a limit number of countries. I need to use the API for Indian market, does the SDK support it?

Thanks

Installing dependencies using composer failed

Loading composer repositories with package information
Installing dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

Problem 1

  • The requested package exeu/apai-io 1.0.0 could not be found.
    Problem 2
  • Installation request for exeu/apai-io dev-master -> satisfiable by exeu/apai-io[dev-master].
  • exeu/apai-io dev-master requires ext-curl * -> the requested PHP extension curl is missing from your system.

Potential causes:

A typo in the package name
The package is not available in a stable-enough version according to your minimum-stability setting see https://groups.google.com/d/topic/composer-dev/_g3ASeIFlrc/discussion for more details.

Read http://getcomposer.org/doc/articles/troubleshooting.md for further common problems.

my composer.json file content as follows:
{
"name": "exeu/apai-io",
"type": "library",
"description": "Amazon Product Advertising PHP Library",
"keywords": ["Amazon", "ECS", "Product Advertising", "SOAP", "REST", "Products"],
"homepage": "https://github.com/Exeu/apai-io",
"license": "Apache-2.0",
"authors": [
{
"name": "Jan Eichhorn",
"email": "[email protected]",
"role": "Maintainer"
},
{
"name": "Dejan Spasic",
"email": "[email protected]",
"role": "Developer"
}
],
"support": {
"issues": "https://github.com/Exeu/apai-io/issues"
},
"minimum-stability": "dev",
"require": {
"php": ">=5.3.0",
"ext-curl": "*"
},
"require": {
"exeu/apai-io": "dev-master"
},
"autoload": {
"psr-0": { "ApaiIO": "lib/" }
}
}

Cache

Would it be possible to implement some cache functionality?

Question: How to integrate into wordpress

I am new to web development.

Any suggestions on how to integrate this library into Wordpress? I have installed the package via Composer, but would love a bit of explanation (or a tutorial!) on where to place the "configuration" and "operation" code mentioned here: http://exeu.github.io/apai-io/basic-usage.html.

Would this go within the Wordpress functions.php file? Can I place it somewhere else to allow for easy upgrades of my theme's functions.php file (I'm using this excellent Wordpress + zurb foundation theme: https://github.com/olefredrik/FoundationPress).

Finally, can anyone recommend basic tutorials on how to use web services like apai-io within wordpress?

THANKS!

Request Rest class should use curl

The Class ApaiIO\Request\Rest\Request class should use the curl extension for the request. The benefits are you have the posiblity to sett the timeout connection and to follow redirects.

Support for Amazon.in

I guess the library don't support amazon.in right now. So, please add support for recently launched Amazon India. Thanks!

Problem with ResponseTransformers

Perhaps I got the syntax wrong, but every ResponseTransformer returns "empty"

<?php
/**/

    require_once "{omitted}/vendor/autoload.php";

    use \ApaiIO\Configuration\GenericConfiguration;
    use \ApaiIO\Operations\Search;
    use \ApaiIO\ApaiIO;
    use \ApaiIO\ResponseTransformer\ObjectToArray;

    $ObjectToArray = new ObjectToArray();

    $x = new \ApaiIO\Request\Rest\Request(
        array(
            \ApaiIO\Request\Rest\Request::FOLLOW_LOCATION => 0
        )
    );

    $conf = new GenericConfiguration($x);

    try 
    {
        $conf
        ->setCountry('de')
        ->setAccessKey($modx->getOption('amazon.access.key.id'))
        ->setSecretKey($modx->getOption('amazon.secret.access.key'))
        ->setAssociateTag($modx->getOption('amazon.associate.tag'))
        ->setRequest($x);

        if(isset($ObjectToArray)){
            $conf->setResponseTransformer($ObjectToArray);
        }
    } 
    catch (\Exception $e) 
    {
        return $e->getMessage();
    }

    $apaiIo = new ApaiIO($conf);


    /* Start: Search */
    $search = new Search();
    $search->setCategory('Books');
    $search->setAuthor('Steve Jackson');
    $search->setKeywords('Fighting Fantasy');
    $search->setCondition('Used');  
    /* End: Search */

    $response = $apaiIo->runOperation($search);

    var_dump($response);

    // return $response;

Without ResponseTransformer I get a nice string:

string(18023) "...."

The string includes all the stuff I expect.

But if I want to use a Response Transformer (for example: ObjectToArray) I get this result:

array(0) { }

In my error log I find this message:

[2015-04-24 14:48:59](ERROR @ {omitted}/vendor/exeu/apai-io/lib/ApaiIO/ResponseTransformer/ObjectToArray.php : 45) PHP warning: Invalid argument supplied for foreach()

It seems foreach() inside buildArray($object) doesn't get a valid object.

Any idea whats going on here?

pepebe

Errors

When ever I try to use the command

php composer.phar install I get this error

The requested package exeu/apai-io 1.0.0 could not be found.

This is my composer.json
{
"name": "exeu/apai-io",
"type": "library",
"description": "Amazon Product Advertising PHP Library",
"keywords": ["Amazon", "ECS", "Product Advertising", "SOAP", "REST", "Products"],
"homepage": "https://github.com/Exeu/apai-io",
"license": "Apache-2.0",
"authors": [
{
"name": "Jan Eichhorn",
"email": "[email protected]",
"role": "Maintainer"
},
{
"name": "Dejan Spasic",
"email": "[email protected]",
"role": "Developer"
}
],
"support": {
"issues": "https://github.com/Exeu/apai-io/issues"
},
"minimum-stability": "dev",
"require": {
"php": ">=5.3.0",
"ext-curl": "*",
"exeu/apai-io": "dev-master"
},
"autoload": {
"psr-0": { "ApaiIO": "lib/" }
}

Can you please tell my why it's not working when I have added the correct line you told me too?
}

Help to format proper request for gettings items in a node.

To anyone who can help:

I have one issue in two parts.

Part I.
Will someone help me determine how I can I get a list of items (... the first 10 results would be fine ...) from a node when I provide the node number? The short story is that Amazon does not provide RSS feeds for some of its nodes ... for example node 3445246011. However, even though there is not an RSS feed for this node, there are still products available. http://www.amazon.com/l/3445246011

use ApaiIO\ApaiIO;
use ApaiIO\Configuration\GenericConfiguration;
use ApaiIO\Operations\Search;

$conf = new GenericConfiguration();

try {
    $conf
        ->setCountry('com')
        ->setAccessKey('***')
        ->setSecretKey('***')
        ->setRequest('\ApaiIO\Request\Rest\Request')
        ->setAssociateTag('***');

} catch (\Exception $e) {
    echo $e->getMessage();
}
$apaiIO = new ApaiIO($conf);

$search = new Search();
$search->setBrowseNode(3445246011);
$search->setResponseGroup(array('Medium'));
$response = $apaiIO->runOperation($search);
$response = json_decode (json_encode (simplexml_load_string ($response)), true);

echo '<pre>';
print_r ($response);
echo '</pre>';

Part II.
In a perfect world, I would have apai-io create a properly formatted request and then I would use another piece of software -- Zebra_cURL -- to grab the properly formatted feed and cache the response from that feed locally. In this manner, I would avoid hammering the Amazon API. However, I don't think it's possible to view the properly formatted feed that apai-io creates -- or is it?

Thanks!

Feature-Request - Search Index?

One way I deal with the Search Index values is by just creating a simple constants container object. This is helpful for purposes of being expressive while also being "code completion" friendly in my IDE ( which is more productive for me at least ). I'm sure there are number of other ways to do this same thing ( global constants, enums, whatever )

A list like this would also add the convenience of not needing go through the documentation to check if SearchIndex values changed ( with new/removed items just being documented in the release notes ).

Anyways, here is an example ( SearchIndex, in this case, only represents US indexes - since those are all that I need. ):

<?php
namespace MyApp;
class SearchIndex {
    const ALL = 'All';
    const APPLIANCES = 'Appliances';
    const ARTS_AND_CRAFTS = 'ArtsAndCrafts';
    const AUTOMOTIVE = 'Automotive';
    const BABY = 'Baby';
    const BEAUTY = 'Beauty';
    const BLENDED = 'Blended';
    const BOOKS = 'Books';
    const CLASSICAL = 'Classical';
    const COLLECTIBLES = 'Collectibles';
    const DIGITAL_MUSIC = 'DigitalMusic';
    const DVD = 'DVD';
    const ELECTRONICS = 'Electronics';
    const GOURMET_FOOD = 'GourmetFood';
    const GROCERY = 'Grocery';
    const HEALTH_PERSONAL_CARE = 'HealthPersonalCare';
    const HOME_GARDEN = 'HomeGarden';
    const INDUSTRIAL = 'Industrial';
    const JEWELRY = 'Jewelry';
    const KINDLE_STORE = 'KindleStore';
    const KITCHEN = 'Kitchen';
    const LAWN_GARDEN = 'LawnAndGarden';
    const MAGAZINES = 'Magazines';
    const MARKETPLACE = 'Marketplace';
    const MISCELLANEOUS = 'Miscellaneous';
    const MOBILE_APPS = 'MobileApps';
    const MP3_DOWNLOADS = 'Mp3Downloads';
    const MUSIC = 'Music';
    const MUSICAL_INSTRUMENTS = 'MusicalInstruments';
    const MUSIC_TRACKS = 'MusicTracks';
    const OFFICE_PRODUCTS = 'OfficeProducts';
    const OUTDOOR_LIVING = 'OutdoorLiving';
    const PC_HARDWARE = 'PCHardware';
    const PET_SUPPLIES = 'PetSupplies';
    const PHOTO = 'Photo';
    const SHOES = 'Shoes';
    const SOFTWARE = 'Software';
    const SPORTING_GOODS = 'SportingGoods';
    const TOOLS = 'Tools';
    const TOYS = 'Toys';
    const VIDEO = 'Video';
    const VIDEO_GAMES = 'VideoGames';
    const WATCHES = 'Watches';
    const WIRELESS = 'Wireless';
    const WIRELESS_ACCESSORIES = 'WirelessAccessories';
}

Usage is then pretty easy:

<?php
// ....
uses MyApp\SearchIndex as SearchIndex;
echo SearchIndex::SOFTWARE;
?>

Supporting multiple countries would be easy enough ( SearchIndex contains the constants accessible by everyone, ALL, BOOKS, ELECTRONICS, with subclasses (like US) supplying the missing ones ( like APPAREL, GOURMET_FOOD, etc. ).

<?php
namespace ApaiIO\SearchIndex;
class US extends SearchIndex {
  const APPAREL = 'Apparel';
  // etc...
}

Still simple to use:

<?php
//...
uses ApaiIO\SearchIndex\US as SearchIndex;
echo SearchIndex::ALL;
echo SearchIndex::APPAREL;
?>

I could then just do any number of things with this, like create my own SearchIndex by country for a specific topic, like Tech.

<?php
// ...
namespace MyApp\SearchIndex;

uses ApaiIO\SearchIndex\US as Idx;

class Tech  {
    public static $searchIndexes = array( Idx::BOOKS, Idx::MOBILE_APPS, Idx::PC_HARDWARE, Idx::SOFTWARE );
}

Anyways - thought i'd throw it out there... Could expand on this with categories and others if ya wanted to too ๐Ÿค˜

An error occurred while setting 52 with value 1

Offline all working fine, but online I get this error:

[message:protected] => An error occurred while setting 52 with value 1
[string:Exception:private] =>
[code:protected] => 0
[file:protected] => /ApaiIO/exeu/apai-io/lib/ApaiIO/Request/Rest/Request.php
[line:protected] => 143

What this error means? I use online centOS 6.5 (Final) with PHP 5.5.6

yum install php-curl
Package php-common-5.4.27-33.el6.art.x86_64 already installed and latest version

Request.php:

    foreach ($options as $currentOption => $currentOptionValue) {
        if (false === @curl_setopt($ch, $currentOption, $currentOptionValue)) {
            throw new \RuntimeException(
                sprintf(
                    "An error occurred while setting %s with value %s",
                    $currentOption,
                    $currentOptionValue
                )
            );
        }
    }

Response impossible to treat

$response = $apaiIo->runOperation($search) returns a long string depending on the response group chosen. It is impossible for me to convert it to the XML form described in amazon documentation. Is there something that I forgot or do I need to parse this string ?

Thank you for this incredible work !

Add Support for Batch Requests

Please add a feature to this framework to enable submitting batch requests to the API.

I'm referring to what's documented in Amazon's Product Advertising API Developer Guide, starting page 71, Batch Requests (enabling 2 different requests to be sent simultaneously and responded to simultaneously).

It would enable REST requests, for example, to use

Operation.1.ParameterName=ParameterValue
Operation.2.ParameterName=ParameterValue
Operation.Shared.ParameterName=ParameterValue

This would enable, for example, getting 2 consecutive pages totaling 20 products, without waiting 1 second between requests. (I'd need it to work with SOAP requests, too.)

Need error handling when connect attempt fails.

Recommend to re-attempt to connect after a few seconds of delay when first attempt was not successful.

[11-Jan-2015 09:27:55 GMT] PHP Fatal error: Uncaught SoapFault exception: [HTTP] Could not connect to host in /home/***/public_html/__Apai-IO/vendor/exeu/apai-io/lib/ApaiIO/Request/Soap/Request.php:152

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.