Wordpress plugin to connect to a REST API? [closed

2019-03-11 22:41发布

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).

4条回答
贼婆χ
2楼-- · 2019-03-11 22:51

If I understand your post correctly, perhaps this would do the trick.

http://wordpress.org/extend/plugins/json-api/

It has 3 controllers:

Post: create_post

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

Respond: submit_comment

查看更多
Juvenile、少年°
3楼-- · 2019-03-11 22:53

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:

查看更多
来,给爷笑一个
4楼-- · 2019-03-11 23:02

Look at this URL, it will solve your problem https://codex.wordpress.org/HTTP_API

查看更多
Rolldiameter
5楼-- · 2019-03-11 23:07

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:

http://codex.wordpress.org/AJAX_in_Plugins

Thanks to moimikey for mentioning WP's ajax ability.

查看更多
登录 后发表回答