webflow-php-sdk
webflow-php-sdk copied to clipboard
[V2 Api] Basic changes required for api v2 to work
This is a first go at a V2 upgrade of the library. @wivern-co-uk
This is the basic changes I needed to make to ensure that the V2 api works with my code. There may be things in the existing code that are broken that I have missed as my code doesnt touch them.
I have put some comments in the code on things that I am looking for feedback on (feedback on anything else is also welcomed)
- #18
Updates
Basically I have made the following updates
- Endpoint has been changed.
- Changed any relevant field names that are in the code eg
_draft
toisDraft
- Create and Update item
fields
changed tofieldData
- Some function parameter types changed to mixed
- error parse code updated to new fields.
- Added
publishItem
which allows a collection item to be published rather than entire site.
Issues
- If library is released it should be released at a new Major version as it will break existing installations.
- Non library code needs to be changed quite substantially, the layout of data returned from webflow has changed. eg Data I think used to be returned a root eg
{
id: 12345abcdef
name: 'this is the name'
otherfields : 'otehr fields'
}
now the structure is
{
id: 12345abcdef
fieldData: {
name: 'this is the name'
otherfields : 'otehr fields'
}
}
Setup
In order to use the V2 library you simply need to go to webflow and generate a new V2 api key and use that.
User will need to make some changes to their own code in structure and field names.
Changes
Some notes on what moving to V2 means for people with codebases. These are notes based on my experience and probably not comprehensive.
https://docs.developers.webflow.com/data/changelog/webflow-api-changed-endpoints
Field Names
- Any field name that begins with
_
has been changed. - All fields are now camelCase
- Field data is now one level down below
fieldData
property.
Methods
Retrieving Items
$webflow->itemsAll($collectionId);
$webflow->item($collectionId, $itemId);
now return a differnt structure. Meta data is at the top level and the fields are one level below in a fieldData
property. This will require changes to client code.
Publish Site
Publish site used to require that you passed an array containing a sub array 'domains' this has now changed and it just requires the user to pass a list of domain strings or domain ids
Publish Item
This is a new api end point for V2 and allows items in collections to be published without publishing the entire site.