cpliakas / magento-client-php
一个PHP客户端库,用于调用Magento的REST和XMLRPC API
0.1.1
2014-02-20 04:14 UTC
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-08-25 12:56:39 UTC
README
提供客户端库以向Magento实例发送REST和XMLRPC调用。
安装
可以使用Composer通过将其添加到项目的composer.json文件中作为依赖项来安装PHP Magento客户端库。
{ "require": { "cpliakas/magento-client-php": "*" } }
在命令行上运行 php composer.phar update
后,请在PHP脚本中包含自动加载器,以便使SDK类可用。
require_once 'vendor/autoload.php';
有关更详细安装和使用说明,请参阅Composer文档。
使用方法
XMLRPC
以下示例返回以"123"开头的SKU的产品列表
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
以下示例返回产品列表
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();
有关向服务器发送请求的更多信息,请参阅Guzzle文档。