定制 nicdev/webflow-sdk 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

nicdev/webflow-sdk

最新稳定版本:0.6.4

Composer 安装命令:

composer require nicdev/webflow-sdk

包简介

Use all the features offered by the Webflow API

README 文档

README

BEWARE! This is a super early version in active development. So please be careful if you decide to use it ✌️

This is open source software and not in any official way supported by Webflow.

This PHP SDK allows you to interact with the Webflow API easily.

There are two main ways to use this library. By accessing Sites and other entities and interacting with their respective classes or...

See the Entities documentation

...directly as an API wrapper through the underlying Webflow class.

See the API client wrapper documentation

Table of Contents

Installation

Install the SDK via Composer:

composer require nicdev/webflow-sdk

Usage

Client (API Wrapper)

To use this SDK, first create a new instance of the Webflow class with your API token.

use Nicdev\WebflowSdk\Webflow;

$token = 'your-webflow-api-token';
$webflow = new Webflow($token);

Get the current user's information

$user = $webflow->user();

Get the authenticated user's authorization information

$authInfo = $webflow->authInfo();

List all sites associated with the authenticated user

$sites = $webflow->listSites();

Fetch a specific site by its ID

$site = $webflow->getSite($siteId);

Publish a specific site by its ID

$webflow->publishSite($siteId);

List all domains associated with a specific site by its ID

$domains = $webflow->listDomains($siteId);

List all webhooks associated with a specific site by its ID

$webhooks = $webflow->listWebhooks($siteId);

Fetch a specific webhook associated with a specific site by their IDs

$webhook = $webflow->getWebhook($siteId, $webhookId);

Create a webhook for a specific site

use Nicdev\WebflowSdk\Enums\WebhookTypes;

$triggerType = WebhookTypes::SITE_PUBLISH;
$url = 'https://your-webhook-url.com';
$filter = []; // Optional filter array

$webflow->createWebhook($siteId, $triggerType, $url, $filter);

Delete a webhook for a specific site

$webflow->deleteWebhook($siteId, $webhookId);

List all collections for a specific site

$collections = $webflow->listCollections($siteId);

Fetch a specific collection by its ID

$collection = $webflow->fetchCollection($collectionId);

List items for a specific collection by its ID

$page = 1; // Optional page number

$items = $webflow->listItems($collectionId, $page);

Create an item in a specific collection by its ID

$fields = [
    'field-name' => 'field-value',
    // ...
];
$live = false; // Optional live mode

$item = $webflow->createItem($collectionId, $fields, $live);

Get an item by its ID

$item = $webflow->getItem($collectionId, $itemId)

Publish one or more items by their ID

$itemIds = ['your-item-id', 'your-other-item-id'];
    
$webflow->publishItems($collection, $itemIds);

Update an item by its ID

$fields = $fields = [
    'field-name' => 'field-value',
    // ...
];
$live = false; // Optional publish 

$webflow->updateItem($collectionId, $itemId, $fields, $live)

Patch an item by its ID

I don't see a real difference between the update and patch methods but they have been matched to their respective endpoints. For more information see the documentation.

$fields = $fields = [
    'field-name' => 'field-value',
    // ...
];
$live = false; // Optional publish 

$webflow->updateItem($collectionId, $itemId, $fields, $live)

Delete or un-publish an item by its ID

$live = true; // Optional. When set to true the item will be un-published but kept in the collection

$webflow->deleteItem($collectionId, $itemId, $live)

List products/SKUs for a specific site by its ID.

$page = 1; // Optional page number
$webflow->listProducts($siteId, $page);

Create a Product and SKU

$product = [
    'slug' = 'foo-bar',
    'name' => 'Foo Bar',
];
$sku = [
    'slug' => 'foo-bar-small',
    'name' => 'Foo Bar (S)',
    'price' => [
        'value' => 990,
        'unit' => 'USD'
    ]
]; // Optional
$webflow->createProductAndSku($siteId, $product, $sku)

Get Products and SKUs

$webflow->getProduct($site, $product);

Update a Product

$fields = [
    'name' => 'New Foo Bar',
    '_archived' => true
];

$webflow->updateProduct($siteId, $productId, $fields);

Create a SKU

$sku = [
    'slug' => 'foo-bar-Medium',
    'name' => 'Foo Bar (M)',
    'price' => [
        'value' => 1190,
        'unit' => 'USD'
    ]
];
$webflow->createSku($siteId, $product, $sku);

Update a SKU

$sku = [
    'slug' => 'foo-bar-Medium',
    'name' => 'Foo Bar (M) Discounted!!',
    'price' => [
        'value' => 1290,
        'unit' => 'USD'
    ]
];

$webflow->updateSku($siteId, $productId, $skuId, $sku);

Inventory for a specific item

$collectionId = 'your-collection-id'; //likely to be the SKUs collection.
$webflow->getInventory($collectionId, $skuId)

Update Inventory

$fields = [
    'inventory_type' => 'infinite'
];

$webflow->updateInventory($collectionId, $skuId, $fields);

List orders

$page = 1; // Optional page number

$items = $webflow->listOrders($collectionId, $page);

Get an Order

$webflow->getOrdr($siteId, $orderId)

Update an Order

$fields = [
    'comment' => 'Adding a comment to this order'
];

$webflow->updateOrder$siteId, $orderId, $fields);

Fulfill an Order

$notifyCustomer = true; // Optional, defaults to false

$webflow->fullfillOrder($siteId, $orderId, $notifyCustomer);

Un-fulfill an Order

$webflow->unfulfillOrder($siteId, $orderId);

Refund an Order

$webflow->refundOrder($siteId, $orderId);

Get Ecommerce settings for a Site

$webflow->getEcommerceSettings($siteId);

Entities

To use this SDK, first create a new instance of the Webflow class with your API token.

use Nicdev\WebflowSdk\Webflow;

$token = 'your-webflow-api-token';
$webflow = new Webflow($token);

Get sites

$sites = $webflow->sites; // [Site $site1, Site $site2...]
// or
$sites = $webflow->sites()->list(); // [Site $site1, Site $site2...]

Fetch a specific site by its ID

$site = $webflow->sites($siteId) // Site $site;
// or
$site = $webflow->sites()->get($siteId) // Site $site;

Publish a domain

$site->publish();

Get a site's domains

$webflow->sites($siteId)->domains();
// or
$webflow->sites($siteId)->domains;

Get site's collections

$site->collections; // [Collection $collection1, Collection $collection2, ...]
// or
$site->collections(); // [Collection $collection1, Collection $collection2, ...]

Fetch a specific collection by its ID

$site->collections($collectionId) // Collection $collection;

Fetch a collection's items

$site->collections($collectionId)->items(); // [Item $item1, Item $item2, ...]
// or
$site->collections($collectionId)->items; // [Item $item1, Item $item2, ...]

Fetch a site's webhooks

$site->webhooks(); // [Webhook $webhook1, Webhook $webhook2, ...]
// or
$site->webhooks; // [Webhook $webhook1, Webhook $webhook2, ...]

Fetch a site's products

$site->products(); // [Product $product1, Product $product2, ...]
// or
$site->products; // [Product $product1, Product $product2, ...]

Fetch a site's orders

$site->webhooks(); // [Order $order1, Order $order2, ...]
// or
$site->webhooks; // [Order $order1, Order $order2, ...]

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

License

This SDK is licensed under the MIT License. See LICENSE for more information.

统计信息

  • 总下载量: 68
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 6
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 5
  • Watchers: 2
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-04-19

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固