-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[V2 Api] Basic changes required for api v2 to work #19
base: master
Are you sure you want to change the base?
Conversation
if (isset($json->code) && isset($json->message)) { | ||
$error = $json->message; | ||
if (isset($json->details)) { | ||
$error .= PHP_EOL . $json->code . ': ' . implode(PHP_EOL, $json->details) ; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would like to ensure that implode(PHP_EOL, $json->details) will work when details has info. I didnt get these errors.
} | ||
throw new \Exception($error, $json->code); | ||
throw new \Exception($error); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
new json->code is a string not a number, do we want to pick an error code to return?
]; | ||
$data = (object) [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This little bit of code could probably be a little more compact
Thanks for filing a PR @tobya What you think is missed to remove Draft status? However I'll manage to check it only at the end of next week. |
I think most of the basic changes are there. I would like someone else to test it a little :) I have only used it for my requirements so there may be stuff missed. |
Webflow support replied to me in reference to the sitepublish issue so I'll test out that fix and push. |
@wivern-co-uk I'm using this now in my own code to connect via Webflow Api V2 and it seems to be working fine. So it can probably be merged. Any additional testing by you or other users would be good. |
Sounds good, I'll let you know once there is a feedback on testing. |
This seems to be working fine on my project on v2 so you can merge it if you wish to see if anyone else is looking for v2 support. |
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)
Updates
Basically I have made the following updates
_draft
toisDraft
fields
changed tofieldData
publishItem
which allows a collection item to be published rather than entire site.Issues
now the structure is
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
_
has been changed.fieldData
property.Methods
Retrieving Items
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.