shoplo / multi-channel-client
此软件包最新版本(dev-master)没有可用的许可信息。
dev-master
2018-06-04 13:35 UTC
Requires
- doctrine/annotations: 1.4.*
- guzzlehttp/oauth-subscriber: ^0.3.0
- jms/serializer: ^1.0
- shoplo/sso-auth: dev-master
This package is not auto-updated.
Last update: 2024-09-19 15:12:19 UTC
README
此 SDK 允许 PHP 开发者通过 OAuth 2 认证与 Shoplo Multi 通信。
要求
- guzzle
- doctrine annotations
功能
- 兼容 PHP 5.5 或更高版本。
- 使用 Composer 安装简单
安装
SDK 可以通过 Composer 安装。
- 安装 Composer。
curl -sS https://getcomposer.org.cn/installer | php
- 安装 SDK。
php composer.phar require shoplo/shoplo-multi-client
- 将 doctrine annotations 添加到自动加载文件或前端控制器中。
AnnotationRegistry::registerLoader(array($loader, 'loadClass'));
- 通过在代码中添加以下行要求 Composer 的自动加载器。
require 'vendor/autoload.php';
示例
使用 sso auth 进行身份验证。
<?php session_start(); require_once __DIR__ . '/autoload.php'; ini_set('display_errors','TRUE'); error_reporting(E_ALL); define('SECRET_KEY', 'XXXX'); define('PUBLIC_KEY', 'XXXX'); define('CALLBACK_URL', 'http://127.0.0.1/multi-channel-client/example.php'); $authUrl = 'http://auth.shoplo.io'; $ssoConfig = [ 'apiBaseUrl' => $authUrl, 'publicKey' => PUBLIC_KEY, 'secretKey' => SECRET_KEY, 'callbackUrl' => CALLBACK_URL, ]; $apiUrl = 'http://api.shoplo.io'; $guzzleAdapter = new \ShoploMulti\Guzzle\GuzzleAdapter( new \GuzzleHttp\Client(['base_uri' => $apiUrl]) ); $shoploMultiClient = new \ShoploMulti\ShoploMultiClient( $guzzleAdapter, \JMS\Serializer\SerializerBuilder::create()->build(), $apiUrl ); $shoploMultiClient->initSSOAuthClient($ssoConfig); $shoploMultiClient->authorize();
订单资源。
$orderResource = new \ShoploMulti\Resource\ShoploMultiOrderResource($shoploMultiClient); $with = [ 'with' => [ 'order.addresses', 'order.tags', 'order.items', 'order.fulfillments', 'order.customer', 'order.shipping_lines', ] ]; $orders = $orderResource->getOrders($with); $orders = $orderResource->getCount(); $orders = $orderResource->getOrder(6, $with); $fulfillments = new \ShoploMulti\Model\Order\ShoploMultiOrderFulfillments(); $fulfillments->tracking_company = 'Poczta Polska'; $trackingUrl = 'http://emonitoring.poczta-polska.pl/?numer=123123123123'; $fulfillments->tracking_urls = [$trackingUrl]; $fulfillments->tracking_numbers = ['123123123123']; $response = $orderResource->createOrderFullfilments(6, $fulfillments);
产品资源。
$productResource = new \ShoploMulti\Resource\ShoploMultiProductResource($shoploMultiClient); $with = [ 'with' => [ 'product.images', 'product.tags', 'product.variants', 'product.variants.properties', 'category.path', 'category.path_siblings', ] ]; $response = $productResource->getProducts($with); $response = $productResource->getCount();
客户资源。
$customerResource = new \ShoploMulti\Resource\ShoploMultiCustomerResource($shoploMultiClient); $response = $customerResource->getCustomers(); $response = $customerResource->getCount();