cpliakas / magento-client-php
A PHP client library that consumes Magento's REST and XMLRPC APIs
Installs: 62 759
Dependents: 2
Suggesters: 0
Security: 0
Stars: 55
Watchers: 6
Forks: 24
Open Issues: 9
Requires
- php: >=5.3.3
- guzzle/guzzle: ~3.0
- lstrojny/fxmlrpc: >=0.8,<0.9
Requires (Dev)
- pdepend/pdepend: ~1.0
- phploc/phploc: ~2.0
- phpmd/phpmd: ~1.0
- phpunit/phpunit: ~3.0
- satooshi/php-coveralls: *
- sebastian/phpcpd: ~2.0
This package is auto-updated.
Last update: 2024-10-25 13:20:32 UTC
README
Provides a client library to make REST and XMLRPC calls to a Magento instance.
Installation
Magento Client Library For PHP can be installed with Composer by adding it as a dependency to your project's composer.json file.
{ "require": { "cpliakas/magento-client-php": "*" } }
After running php composer.phar update
on the command line, include the
autoloader in your PHP scripts so that the SDK classes are made available.
require_once 'vendor/autoload.php';
Please refer to Composer's documentation for more detailed installation and usage instructions.
Usage
XMLRPC
The following example returns a list of products with SKUs that start with "123":
use Magento\Client\Xmlrpc\MagentoXmlrpcClient; $client = MagentoXmlrpcClient::factory(array( 'base_url' => 'http://magentohost', 'api_user' => 'api.user', 'api_key' => 'some.private.key', )); $filters = array( 'sku' => array('like' => '123%'), ); $result = $client->call('catalog_product.list', array($filters));
Rest
The following example returns a list of products:
use Magento\Client\Rest\MagentoRestClient; $client = MagentoRestClient::factory(array( 'base_url' => 'http://magentohost', 'consumer_key' => 'abc123...', 'consumer_secret' => 'def456...', 'token' => 'ghi789...', 'token_secret' => 'jkl012...', )); $result = $client->get('/api/rest/products')->send()->json();
Refer to Guzzle's documentation for more information on sending requests to the server.