amzn / selling-partner-api-models

This repository contains OpenAPI models for developers to use when developing software to call Selling Partner APIs.
Apache License 2.0
580 stars 730 forks source link

PHP API client #28

Closed ionafan2 closed 2 years ago

ionafan2 commented 3 years ago

I guess there are a lot of PHP Developers, including myself, who would like to use PHP to work with the seller API. Please.

JacksonJeans commented 3 years ago

[...]"Amazon has released Java and C# clients for the Selling Partner API. MWS has Java, C#, and PHP clients, so I would not be surprised to see a PHP client for SP sometime soon. The Java and C# clients use Swagger code generation (with these endpoint models), so it should be relatively straightforward to implement SP clients in any other language that Swagger can target."[...] Source: https://jesseevers.com/new-amazon-seller-api/

I share Jesse Evers opinion and expertise and also expect Amazon to release a PHP client at some point. But in the meantime you can use Swagger to create a client in PHP. Clousale has already done this: https://github.com/clousale/amazon-sp-api-php

Unfortunately I did not quite get along with the client, because it is not sufficient for my requirements. I have written my own one which is much easier to use. I will not publish it for free yet, because the work was very hard, but I can help with the implementation.

How far have you come so far?

ionafan2 commented 3 years ago

Hi @JacksonJeans , Thanks for the introduction of clousale/amazon-sp-api-php I would probably fork it, add request signature and it's should be just fine for me at this moment. There is actually a fork from @rodrigojob https://github.com/rodrigojob/amazon-sp-api-php he implemented request signing but his approach is not the best. I guess we should use AWS PHP SDK and sign requests with \Aws\Signature\SignatureV4 in \GuzzleHttp\Middleware. Also, we need the \Aws\Sts\StsClient to assumeRole. You can track my progress here https://github.com/staysmartway/amazon-sp-api-php

JacksonJeans commented 3 years ago

@ionafan2 Hello! Sorry for coming back so late. I have already seen other posts by you and have to agree with you. The best way will most likely be the one you describe to cover every use case that is possible with the SP-API. For my purposes I have written a PHP client that uses self authorization, not via a vendor and OAuth. So without any SecurityToken, just using an AccessToken which I ask via STS. You can see my status, how far I have tested everything here: https://github.com/JacksonJeans/amazon-selling-partner-api-php

Regarding the authorization via a provider I will not be able to help you. But everything else I like to do. 😄

Best Regards

Tanveer-LowCoder commented 3 years ago

Not sure if this will help anyone, but I have a server on AWS processing SP API requests. I have listed two of the API's on RapidAPI - https://rapidapi.com/user/integrationhub

Hope this helps.

ionafan2 commented 3 years ago

I did a PR - https://github.com/amzn/selling-partner-api-models/pull/47

jlevers commented 3 years ago

@ionafan2 I know that I'm a little late to the party, but that's my blog post that @JacksonJeans quoted in his first post. In case it's still relevant to you, I just published the PHP library that I started working on when it became clear that Amazon wasn't going to release one themselves. It includes classes that help with authentication, and with the uploading/downloading of report/feed documents, which is IMO the most difficult part of the API to deal with.

Here's the GitHub repository, and here's the package on Packagist. If you end up using it, please let me know if you run into any issues!

JonLaliberte commented 3 years ago

Pretty wild that they're not releasing their own PHP lib...

norberttech commented 3 years ago

If anyone is looking for a decent php lib that does not come with hardcoded guzzle dependency and that supports all APIs feel free to look into this: https://github.com/amazon-php/sp-api-sdk

This lib also comes with everything that is needed to regenerate SDKs and Models whenever Amazon push something new to models repo. One of the requirements that comes from Amazon audits is to log communication with the API and that lib makes that possible and pretty flexible when it comes to configuration.

@JonLaliberte do you really think Amazon could build something better? 😅

github-actions[bot] commented 2 years ago

This is a very old issue that is probably not getting as much attention as it deserves. We encourage you to check if this is still an issue after the latest release and if you find that this is still a problem, please feel free to open a new issue and make a reference to this one.