Open ThomasPe opened 6 years ago
defaultPath just has to be empty for sites hosted by wordpress.com. It could be an optional parameter for the client constructor, to keep the compatibility with older releases.
Good suggestion, I've changed the client accordingly. Can you try if that's how you would expect it to work?
Hi, the client seems to be working, I can get a category.
A new error arose: Cannot deserialize the current JSON object (e.g. {"name":"value"}) into type 'System.Collections.Generic.IList`1[System.Object]' because the type requires a JSON array (e.g. [1,2,3]) to deserialize correctly.
To fix this error either change the JSON to a JSON array (e.g. [1,2,3]) or change the deserialized type so that it is a normal .NET type (e.g. not a primitive type like integer, not a collection type like an array or List
I don't think it's related. I don't find a definition for "meta" in POSTS or PAGES...
I solved it by changing Meta in Models.post and Models.page to "object" instead of iList or iEnumerable. It's for another ticket I think. (json had "meta":{"amp_status":""} ) Bottom line, the client is working great with defaultpath = "".
Since today I'm seeing the same issue.
@ThomasPe, would you mind describing how you got WordPressPCL working on sites hosted on Wordpress.com? My understanding is that they do not provide access to wp-config.php
which is required to modify after installing the JWT Authentication for WP REST API plugin. Thanks.
@hbcondo I'm interested as well if you have a solution. I'm running without the plugin at the moment.
Actually, I have not yet looked at authentication for wordpress.com accounts. As far as I can tell we would need to implement the authentication for wordpress.com separately since that probably won't work with the JWT Authentication plugin (as you've mentioned).
I guess that would be the best starting point: https://developer.wordpress.com/docs/oauth2/
I'm not sure if I'll have enough time to implement this in the next few days or weeks, but maybe someone else wants to take a shot at this.
I'm still interested in using the business account of WordPress.com for hosting so I emailed them about JWT and their response was JTW isn't allowed and Business sites use WordPress.com accounts for authentication even though I explained JWT would be used by a service and not actual users.
I like the idea of supporting different authentication plugins as that would support this issue
This is an old open issue that for me has been resolved as I've been successfully using WordPressPCL with a site hosted with WordPress.com for years now. Thanks for such an awesome library!!
happy it works. can you explain how you did the auth part?
I installed the JWT Authentication for WP REST API plugin and defined JWT_AUTH_SECRET_KEY in the site's wp-config.php
file.
WordPress.com's hosting features were updated signficantly since this issue was created in 2018. Now they provide SFTP/SSH and WP-CLI which made this easier to implement.
Hosted blogs on wordpress.com at least partly support the new REST API V2. For this package to work we would need probably flag hosted vs. selfhosted since the API URL structure is slightly different:
https://public-api.wordpress.com/wp/v2/sites/$wpcom_site/posts
vshttps://$wphosted_site/wp-json/wp/v2/posts