swellstores/swell-php

PHP版本的Swell API库

dev-master 2023-08-23 20:55 UTC

README

Swell 是一个可定制的、以API为第一平台的B2C/B2B购物体验和市场平台。使用您喜欢的技术构建和连接任何东西,并为管理员提供易于使用的仪表板。

示例

require_once("/path/to/swell-php/lib/Swell.php");

$swell = new Swell\Client('my-store', 'secret-key');

$products = $swell->get('/products', [
  'category' => 't-shirts'
]);

print_r($products);

或者通过Composer

composer.json

"require": {
  "swellstores/swell-php": "dev-master"
},
"repositories": [
	{
		"type": "vcs",
		"url": "git@github.com:swellstores/swell-php.git"
	}
]

然后运行 composer update 下载并安装库

require __DIR__ . '/vendor/autoload.php';

$swell = new Swell\Client('my-store', 'secret-key');

$products = $swell->get('/products', [
  'category' => 't-shirts'
]);

print_r($products);

缓存

此库默认启用内存缓存,使用版本协议意味着您无需担心缓存过时。不经常变化的记录,如产品,始终会从缓存返回,如果可能的话。

要禁用缓存行为,使用选项 cache: false

$swell = new Swell\Client('my-store', 'secret-key', [
	'cache' => false
]);

文档

API参考:https://developers.swell.is/backend-api/

Swell的前端API(Swell.js)的通用JavaScript客户端:https://github.com/swellstores/swell-js

贡献

欢迎提交拉取请求

许可

MIT