wp-net / WordPressPCL

This is a portable library for consuimg the WordPress REST-API in (almost) any C# application
MIT License
342 stars 130 forks source link

Client constructor appends "wp-json" to the uri #90

Closed Marneus77 closed 6 years ago

Marneus77 commented 6 years ago

Hi,

The wordpress client constructor seems to be appending "/wp-json/" to the uri when it doesn't end with it. This prevents the possibility to use WordPressPCL on Blogs hosted on wordpress.com, for their Rest Api Url is like https://public-api.wordpress.com/wp/v2/sites/{name_of_the_site}.wordpress.com/

ThomasPe commented 6 years ago

Ah, I had not seen yet that wordpress.com supports the new REST API as well. We should certainly enable this!

Marneus77 commented 6 years ago

How long do you think it will take?

ThomasPe commented 6 years ago

It's gonna be a bit more work than just omitting the /wp-json/ since the default paths baked into the sub-methods (e.g. /wp/v2/comments) will have to be touched as well. Not sure yet whether we should add a flag for wordpress.com sites. Also, we'll have to figure out how authentication will work with wordpress.com sites.

Marneus77 commented 6 years ago

I saw that with a business plan you can install the jwt authentication plugin. I'll wait or find another way. Thanks for the great support.

Marneus77 commented 6 years ago

I had a look at the code, and saw that the wp-json at the end was added with pull 78. (WordPressClient.cs, line 140) The defaultPath (/wp/v2/) used for requests could then effectively be changed with a flag.

ThomasPe commented 6 years ago

I just updated the nuget package with a fix to not append /wp-json to the uri anymore. Still, that won't be enough to get wordpress.org sites working just yet.

Marneus77 commented 6 years ago

Thanks for the info. I compiled a version for me in the meantime. It's working great.

ThomasPe commented 6 years ago

Ok, I'll close this for now and will open another issue explicitly for wordpress.com support.