shoppingfeed / php-sdk
Shopping Feed SDK to ease integration of our API
Installs: 167 122
Dependents: 3
Suggesters: 0
Security: 0
Stars: 4
Watchers: 11
Forks: 12
Open Issues: 5
Requires
- php: >=7.1
- ext-json: *
- symfony/deprecation-contracts: ^2.5|^3.0
Requires (Dev)
- guzzlehttp/guzzle: ^6.0 | ^7.0
- monolog/monolog: ^1.23
- overtrue/phplint: ^1.1
- phpstan/phpstan: ~1.4.0
- phpunit/phpunit: ^7.0 | ^9.0
- shoppingfeed/coding-style-php: ~2.1.0
Suggests
- guzzlehttp/guzzle: Guzzle Http 6 is the default http adapter integrated in the SDK
- psr/log: trace HTTP requests performed by the SDK
- shoppingfeed/php-feed-generator: Generates compliant Shopping-Feed XML feed with ease
- dev-master
- 0.12.0
- 0.11.1
- 0.11.0
- 0.10.0
- 0.9.0
- 0.8.0
- 0.7.0
- 0.6.0
- 0.5.2
- 0.5.1
- 0.5.0
- 0.4.2
- 0.4.1
- 0.4.0
- 0.3.3
- 0.3.2
- 0.3.1
- 0.3.0
- 0.2.7
- 0.2.6
- 0.2.5
- 0.2.4
- 0.2.3
- 0.2.2-beta.1
- 0.2.1-beta.1
- 0.2.0-beta.1
- dev-fix-legacy-order-operations
- dev-view-all-orderitem-properties
- dev-add-cursor-hallink
- dev-SFCORE-2829
- dev-SFCORE-2849
- dev-fix_type_issue
- dev-retry-on-499
- dev-fix_rejected_callback
- dev-php71-upgrade
- dev-fix_php81_deprecation
- dev-olivierh94-github-action-php
- dev-add_missing_store_fields
- dev-client-adapter
- dev-handle_body_for_delete
- dev-fix_empty_response
This package is auto-updated.
Last update: 2024-12-11 10:42:08 UTC
README
Install
- In your project root repository run
composer require shoppingfeed/php-sdk
- Install a http client of your choice, we recommend using GuzzleHttp 6 as the SDK embed an adapter for this client.
composer require guzzlehttp/guzzle ^6.3
You can also develop your own adapter, if you already have a http client library in your project (see the http adapter documentation for more information).
This will load the SDK library into the vendor
repository.
And thanks to PSR-4 specification you should be able to access the SDK under the namespace \ShoppingFeed\Sdk
.
Basic usage
Here are the three basic steps to use the SDK :
- Authentication to start a new session
- Retrieve the store(s) you want to manage from the session
- Manage resources
Authentication against the API
The Shopping Feed API requires that you are authenticated to perform any calls.
In order to make authenticated call, you should build the client like so:
<?php namespace ShoppingFeed\Sdk; // Setup credentials to connect to the API, and create session $credential = new Credential\Token('api-token'); /** @var \ShoppingFeed\Sdk\Api\Session\SessionResource $session */ $session = Client\Client::createSession($credential);
Accessing your stores
/** @var \ShoppingFeed\Sdk\Api\Session\SessionResource $session */ $store = $session->selectStore(1276); $store->getName(); // test-store $store->getId(); // 1276 // ... and so on
If you manage more than one store, you can use the store collection object
/** @var \ShoppingFeed\Sdk\Api\Session\SessionResource $session */ // Get store collection $stores = $session->getStores(); // Count the number of stores [int] $stores->count(); // Get a particular store $store = $stores->select('id-or-store-name'); // Loop over available stores foreach ($stores as $store) { $store->getName(); }
SDK guides
SDK resources documentation
Generates XML compliant feed for import
The SDK is able to simplify XML feed creation by providing necessary tools.
Check the documentation at https://github.com/shoppingflux/php-feed-generator to learn how to create compliant feed.