Download the PHP package ceresaconsultoria/sdk-php-nuvemshop without Composer
On this page you can find all versions of the php package ceresaconsultoria/sdk-php-nuvemshop. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download ceresaconsultoria/sdk-php-nuvemshop
More information about ceresaconsultoria/sdk-php-nuvemshop
Files in ceresaconsultoria/sdk-php-nuvemshop
Package sdk-php-nuvemshop
Short Description A PHP SDK for the Tienda Nube/Nuvem Shop API.
License MIT
Informations about the package sdk-php-nuvemshop
Tienda Nube/Nuvem Shop SDK for PHP
This SDK provides a simplified access to the API of Nuvem Shop / Tienda Nube.
Installation
This SDK is mounted on top of Requests for PHP, so we recommend using Composer for installing.
Simply add the ceresaconsultoria/sdk-php-nuvemshop
requirement to composer.json.
Then run composer install
or composer update
to complete the installation.
If you need an autoloader, you can use the one provided by Composer:
Authenticating Your App
When a user installs your app, he will be taken to your specified Redirect URI with a parameter called code
containing your temporary authorization code.
With this code you can request a permanent access token.
The returned value will contain the id of the authenticated store, as well as the access token and the authorized scopes.
Keep in mind that future visits to your app will not go through the Redirect URI, so you should store the store id in a session.
However, if you need to authenticate a user that has already installed your app (or invite them to install it), you can redirect them to login to the Tienda Nube/Nuvem Shop site.
After the user has logged in, he will be taken to your specified Redirect URI with a new authorization code. You can use this code to request a new request token.
Making a Request
The first step is to instantiate the API
class with a store id and an access token, as well as a user agent to identify your app. Then you can use the get
, post
, put
and delete
methods.
You can access the headers of the response via $response->headers
as if it were an array:
For convenience, the X-Main-Language
header can be obtained from $response->main_language
:
Other examples:
For list results you can use the next
, prev
, first
and last
methods to retrieve the corresponding page as a new response object.
Exceptions
Calls to Auth
may throw a Tiendanube\Auth\Exception
:
Likewise, calls to API
may throw a Tiendanube\API\Exception
. You can retrieve the original response from these exceptions:
Requests that return 404 will throw a subclass called Tiendanube\API\NotFoundException
.