arielmagbanua/webflow-php-sdk
最新稳定版本:v0.7.1
Composer 安装命令:
composer require arielmagbanua/webflow-php-sdk
包简介
PHP SDK for the Webflow Data API
README 文档
README
PHP Webflow SDK
PHP SDK for the Webflow Data API
Authentication
If you are not using a workspace or site token, you can use the OAuth class to retrieve an access token.
// include the vendor autoload require_once __DIR__ . '/../vendor/autoload.php'; use ArielMagbanua\PhpWebflowApi\DataApi\Versions\V2\Authentication\OAuth; use Dotenv\Dotenv; // load environment variable if API credentials were configured in the environment $dotenv = Dotenv::createImmutable(__DIR__ . '/../'); $dotenv->safeLoad(); // API credentials $clientId = $_ENV['WEBFLOW_CLIENT_ID'] ?? null; $clientSecret = $_ENV['WEBFLOW_CLIENT_SECRET'] ?? null; $state = $_ENV['WEBFLOW_DEFAULT_STATE'] ?? null; $redirectUri = $_ENV['WEBFLOW_REDIRECT_URI'] ?? null; // create OAuth object $oauth = new OAuth( clientId: $clientId, clientSecret: $clientSecret, state: $state, redirectUri: $redirectUri, scopes: [ 'cms:read', 'cms:write', 'authorized_user:read', ] ); // generate authorization url use the URL to authenticate the client $authorizationUrl = $oauth->getAuthorizationUrl();
After successful client authentication, the client will be redirected to the provided redirect url where you can retrieve the authorization code from the query part of the redirect url. Once you retrieve the code, you should be able now to exchange it for access token.
// exchange the authorization code with access token $tokenObject = $oauth->requestAccessToken($code); // get the access token value $accessToken = $tokenObject->getAccessToken();
CMS and Data API Resources Usage
Once you secure your access token via OAuth or if you have already workspace or site token. You can now push or pull data from CMS or other Data API resources.
// include the vendor autoload require_once __DIR__ . '/../vendor/autoload.php'; use ArielMagbanua\PhpWebflowApi\DataApi\Versions\V2\Cms\CollectionItems\LiveItems; use ArielMagbanua\PhpWebflowApi\DataApi\Versions\V2\Cms\CollectionItems\StagedItems; use ArielMagbanua\PhpWebflowApi\DataApi\Versions\V2\Token\Info; // retrieved via OAuth or this can be a provided workspace or site access token $accessToken = 'access_token'; $liveItems = new LiveItems( accessToken: $accessToken, collectionId: 'live_collection_id' // use the correct collection id from CMS ); $stagedItems = new StagedItems( accessToken: $accessToken, collectionId: 'staged_collection_id' ); $tokenInfo = new Info( accessToken: $accessToken ); // information about the Authorized User $tokenInfo->getAuthorizationUserInfo(); // information about the authorization token $tokenInfo->getAuthorizationInfo(); // retrieve live collection items $liveItems = $liveItems->listItems(); // retrieve staged collection items $stagedItems = $stagedItems->listItems();
统计信息
- 总下载量: 85
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 4
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-05-15