• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 312
  • Last Modified:

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
0
Tim Brocklehurst
Asked:
Tim Brocklehurst
  • 2
  • 2
1 Solution
 
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
 
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now