Giter Site home page Giter Site logo

amazon-ecs's Introduction

Amazon ECS (E-Commerce Services) Package for Laravel

If you need the ability to search Amazon's catalog of products or lookup an individual item with Laravel, then this may be the package for you.

Please note, you'll need to ensure you have an associate tag before using this package.

Installation

composer require dawson/amazon-ecs

After you have successfully installed, add the follow Service Provider to your config/app.php.

Dawson\AmazonECS\AmazonECSServiceProvider::class,

And the following facade, also in config/app.php.

'Amazon' => Dawson\AmazonECS\AmazonECSFacade::class

Now we'll go ahead and publish the amazon.php configuration file.

php artisan vendor:publish --provider="Dawson\AmazonECS\AmazonECSServiceProvider"

Open up the amazon.php configuration file and enter your credentials or leverage the use of environment variables which're used by default.

When it comes to choosing a locale, you have a choice of the following:

Locale Country
co.uk United Kingdom
com United States
ca Canada
com.br Brazil
de Germany
es Spain
fr France
in India
co.jp Japan
com.mx Mexico

You should now be correctly configured!

Usage

Currently, there are two methods available which are search and lookup.

Search

$results = Amazon::search('Home Alone')->json();

It's that simple!

Please note, this currently searches the entire Amazon catalog. I plan on adding the ability to search within a given category soon so keep an eye out for that.

Lookup

You can also lookup any given item, assuming it's availble on your configure locale and is a valid ASIN, of which is possible by doing the following:

$product = Amazon::lookup('B004VLKY8M')->json();

This will simply return the product, it's attributes and item links.

Responses

Currently, there are two available response methods. The default xml method, or my preferred - json.

The following returns an XML string.

$xml = Amazon::search('Call of Duty')->xml();

And as you can probably assume, the following returns a JSON string.

$json = Amazon::search('Halo')->json();

Questions & Issues

Should you have any questions or come across a problem, please feel free to submit an issue.

License

This package is open-sourced software licensed under the MIT license.


Planned

  • Finish Documentation
  • Locales
  • Better Exception Handling
  • Cart abilities, such as modifying, adding, clearing etc.
  • XML to JSON (the ECS API returns an XML response, I myself would like to have the ability to convert this to JSON - but optional)

amazon-ecs's People

Contributors

brino avatar joedawson avatar mrandibilbao avatar robertem128 avatar sinepel 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

Watchers

 avatar  avatar  avatar  avatar

amazon-ecs's Issues

Caompatibility with Laravel 5.4

Dear Joe,
It looks like the package is not compatible with Laravel 5.4 is there anyway to fix this issue?

Problem 1                                                                                                                                                                                                        
    - Installation request for symfony/psr-http-message-bridge (locked at v1.0.0) -> satisfiable by symfony/psr-http-message-bridge[v1.0.0].                                                                       
    - dawson/amazon-ecs 1.0.0 requires symfony/psr-http-message-bridge 0.2 -> satisfiable by symfony/psr-http-message-bridge[v0.2].                                                                                
    - dawson/amazon-ecs 1.0.1 requires symfony/psr-http-message-bridge 0.2 -> satisfiable by symfony/psr-http-message-bridge[v0.2].                                                                                
    - dawson/amazon-ecs 1.0.2 requires symfony/psr-http-message-bridge 0.2 -> satisfiable by symfony/psr-http-message-bridge[v0.2].                                                                                
    - dawson/amazon-ecs 1.0.3 requires symfony/psr-http-message-bridge 0.2 -> satisfiable by symfony/psr-http-message-bridge[v0.2].                                                                                
    - Conclusion: don't install symfony/psr-http-message-bridge v0.2                                                                                                                                               
    - Installation request for dawson/amazon-ecs ^1.0 -> satisfiable by dawson/amazon-ecs[1.0.0, 1.0.1, 1.0.2, 1.0.3].  

composer require dawson/amazon-ecs on Laravel 5.6 - Your requirements could not be resolved to an installable set of packages.

Hello thank you for this package - i'm trying to install on a new Laravel 5.6 project and receiving the following error message:

Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Installation request for symfony/http-foundation (locked at v4.0.6) -> satisfiable by symfony/http-foundation[v4.0.6].
    - dawson/amazon-ecs 2.0.1 requires symfony/psr-http-message-bridge 0.2 -> satisfiable by symfony/psr-http-message-bridge[v0.2].
    - dawson/amazon-ecs v2.0.0 requires symfony/psr-http-message-bridge 0.2 -> satisfiable by symfony/psr-http-message-bridge[v0.2].
    - Conclusion: don't install symfony/psr-http-message-bridge v0.2
    - Installation request for dawson/amazon-ecs ^2.0 -> satisfiable by dawson/amazon-ecs[2.0.1, v2.0.0].


Installation failed, reverting ./composer.json to its original content.

Add page attribute to search

Hi,

I needed to include the ability to add pagination to my Amazon search results, I'm not sure my method is the best way but it is working for my use case (basically just submitting an optional "page" attribute with the request). I can submit a pull request, but this might be too much of a "quick and dirty" approach (code below).

Thanks for your work on this package btw, it was really helpful in my project.

public function search($query, $page = 1)
	{
		$query		= rawurlencode($query);
		if ($page == 1) {
			$params 	= $this->params(['Keywords' => $query, 'SearchIndex' => 'All', 'ResponseGroup' => $this->response_group]);
		} else {
			$params 	= $this->params(['Keywords' => $query, 'SearchIndex' => 'All', 'ResponseGroup' => $this->response_group, 'ItemPage'=>$page]);
		}
		$string 	= $this->buildString($params);
		$signature 	= $this->signString($string);
		$url 		= $this->url($params, $signature);

		try {
			$this->response = $this->client->get($url)->getBody();
			return $this;
		} catch(ClientException $e) {
			return $e->getResponse();
		}
	}

order results search

It's possible order by price - relevance and search only in category elettronics - movie etc.?
thanks

Not receiving any items

Hi there,

I included the package for my laravel app. ItemLookup is working and I receive the correct output. For the ItemSearch operation I do not receive any items, so my response looks like this:

bildschirmfoto 2017-09-07 um 10 38 42

The request seems to be valid. AWS keys are correct as well since otherwise the ItemLookup would not work. I tried with several keywords where amazon definitely has products. I deleted my vendor folder and run composer install.

I appreciate any kind of help or ideas what the problem might be!

Cheers,
Sebastian

Call to undefined method json()

Doing a simple:
$bookFromAmazon = Amazon::lookup($bookTitle)->json();
throws an error:
Call to undefined method GuzzleHttp\Psr7\Response::json()do you have any idea why ?

PS: ->xml()gives the same error

Call to undefined method GuzzleHttp\Psr7\Response::json()

Hi I have this error after setting up the package:

Call to undefined method GuzzleHttp\Psr7\Response::json()

and that's my code in the controller which I called it directly from the home controller just for testing.

public function index()
    {
        $results = \Amazon::search('Home Alone')->json();

Thanks in advance, And thank you for the hard work and the time you given to this great project.
Thanks

Hint: I'm using it on Laravel 5.3

can't add more parameters

Dear @joedawson
I already tried and I thought that I can add more parameters into the search method inside AmazonECS class like these lines below but it seems I can't,

$params = $this->params(['Keywords' => $query, 'SearchIndex' => $category, 'ResponseGroup' => 'Images,ItemAttributes,Offers'**, 'Sort' => '-price']**);

And I tried to retrieve all the items inside a category by bypassing the search query like below:
$amazon_results = \Amazon::search('', 'Electronics')->json();
and that's not possible too.

And I can't remove the search 'keyword' inside the search method when I think as I read it on the Amazon API manuals it's possible.
$params = $this->params(['SearchIndex' => $category, 'ResponseGroup' => 'Images,ItemAttributes,Offers']);

manual write for lumen

Hi thanks for your bundle, I've had problem with config file with lumen framework, I've manual write the config file, in amazonECS.php, line 37 write this:
config(['amazon.access_key' => 'xxxxxxxxxxxx']);
config(['amazon.secret_key' => 'xxxxxxxxxxxxxxx']);
config(['amazon.associate_tag' => 'xxxxxxxxxxx']);
config(['amazon.locale' => 'xx']);

Amazon Class not found

hi , what should i do to define Amazon Class in controller ?
my error is : Class 'App\Http\Controllers\Amazon' not found

Suddenly getting 400 response (bad request)

I've been running this package for about 1 year now. Suddenly (within the last month or two?) all amazon requests return a 400 response (bad request). Not sure if something changed in the API or if my keys were disabled or something?

Any insight would be great!
Thanks

Class 'App\Http\Controllers\Amazon' not found

I have the following method in a controller:

public function add()
    {
        $product = Amazon::lookup('B004VLKY8M')->json();
        return $product;

    }

and I'm getting a Class 'App\Http\Controllers\Amazon' not found

I'm not sure what use statement to place in the controller file, I have tried
use Amazon;
use Dawson\AmazonECS\AmazonECS
use Dawson\AmazonECS\Amazon
and many more versons and get the same result.

I have both Dawson\AmazonECS\AmazonECSServiceProvider::class, and 'Amazon' => Dawson\AmazonECS\AmazonECSFacade::class, in my config\app.php file in the correct place.

can't figure out why I am getting this error.

Signature error

Hello,

since this morning, without update the code, I have this error which is triggered by calling the method ->json ();

<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>

I already generated a new Amazon Api key but that does not change anything.
An idea ?
Thank you !

Call to an undefined method json()

Hi,

It seems like an amazing library for my use but I am facing the same issue that was reported earlier.

I tried to check the of status by using "\Amazon::search('Home Alone')->getStatusCode()" and its giving me 400. Can you please check this out for me.

Thanks in advance. :)

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.