Wordpress plugin to connect to a REST API?
Let's say I have a RESTful API running on a server somewhere, as well as a separate, but related, Wordpress site.
I want to have some pages on the WP site that show data on WP pages that has been retrieved from the REST server (in JSON format), and allow the user to view and/or edit the data on WP pages.
For example, let's say I have, as a REST starting point, an API that returns a list of books owned by a user. I want to display the list of books, allow the user to click on a book link and go to a page that displays the details for the book.
Then if the user enters "edit mode", it lets him/her edit the data and POST/PUT it back to the server via the REST API.
Is there any WP plugin that lets me create pages that display and edit information like this?
I would expect that for each type of entity I could enter some metadata to indicate what to expect in the JSON and how to display it for viewing or how to build the form for it (like iPhorms does).
So WordPress has some built-in support for AJAX queries, both from the admin panel and in the user-facing pages.
I don't fully understand how it all works yet as I am totally new to WordPress coding, but this seems to be what I want:
Thanks to moimikey for mentioning WP's ajax ability.
Look at this URL, it will solve your problem https://codex.wordpress.org/HTTP_API
If I understand your post correctly, perhaps this would do the trick.
It has 3 controllers:
Core: info get_recent_posts get_post get_page get_date_posts get_category_posts get_tag_posts get_author_posts get_search_results get_date_index get_category_index get_tag_index get_author_index get_page_index get_nonce
I am looking for similar functionality (I want my Wordpress page to render/update data retrieved from Spring REST CRUD repository) and I couldn't find anything.
I ended up writing my own generic shortcode plugin for Spring REST data repositories, which I will be happy to share once it's completed.
You can also write your own shortcode plugin based on the following tutorials / blog posts, it is fairly straight-forward:
- How to parse json response from CURL
- Call a REST API in PHP