Seeking example VB code for calling Wordpress REST API in a .NET application

I have an existing web app hosted on MS Azure, written using VB in Visual Studio.
We haven't been using the REST API in Wordpress, but would like to now, especially to see if we can call Wordpress' UPDATE procedure for when a post is saved.

Currently, values from fields in a SQL Db are transferred to Wordpress' MySQL Db. It works OK, but we think it will be more efficient to call the UPDATE procedure to save each post 'the Wordpress way' after updating each record.

Can anyone supply some sample code for how we would login to Wordpress and update post_id "xxx" for example, ideally written in VB, although C++ might be workable if I can translate it...

Thank you
Tim
LVL 1
Tim BrocklehurstHead of DigitalAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

David FavorLinux/LXD/WordPress/Hosting SavantCommented:
If one of my hosting clients asked for this type of code, I'd use...

http://wp-cli.org + https://github.com/aaemnnosttv/wp-cli-login-command because...

When accessing WordPress via a logged in user, you have to run the entire WordPress stack to ensure your session management is working.

Trying to duplicate all the human design years put into wp-cli... will be a long, maddening, trail of tears.

Likely best to use wp-cli + be done in a few minutes, rather than invest  months into trying this with VB or some C derivative.
0
Tim BrocklehurstHead of DigitalAuthor Commented:
Thank you David, this is sound advice I'm sure.
However, there is method in the madness for wanting to call the REST api from within .NET:

We already have a sync program which runs on Azure syncing new and updated records through to Wordpress' MySQL. A lot of man-hours have already gone into this and it works well.

All that's missing is the ability to run the 'update' procedure for each post synced, or 'publish' for each post generated in Wordpress. If we were to do that, in the same way as a user does manually, then things like the re-indexing of posts in the Relevanssi search plugin, and other SEO goodies, would be looked after by default.

I have come across the Wordpress PCL which sounds like just what we need, but I've not been able to figure a VB version of it, and we need that because its the language the app is written in.

Thanks for your help, but I must keep searching... any other ideas or experiences welcome.
0
David FavorLinux/LXD/WordPress/Hosting SavantCommented:
If you've gone this far, take a look at https://developer.wordpress.org/rest-api/reference/posts/ under the update posts section. Maybe this will accomplish what you're targeting.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Tim BrocklehurstHead of DigitalAuthor Commented:
Thanks David... this looks like a great starting point. It would seem that its still too early to get any example REST api calls to Wordpress from a vb.net application. However, I have found [url="https://wbsimms.github.io/WordPressRestApi/"]WBSimms' Wordpress REST api Nuget package[/url], and will see if that helps. The main issue I'm having actually is authenticating with Wordpress when there is pre-authorisation in place [i]before[/i] the wp-admin page...

It would be dull if it were too easy, I guess... :)
T
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.