Three very important ( & most requested ) new end points add_post, update_post and delete_post have been added in the JSON API User Plus Plugin. You can also add attachment with add_post and attached image is set as featured image with the post.
Use WordPress not just as as web app but also for your iOS and Android Mobile apps back end. JSON API User Plus Plugin version 1.2 allows you to create, update, and delete Posts among many other features. JSON API User Plus Plugin enables you to use WordPress and BuddyPress (not all features yet, check the documentation for available endpoints) via REST API.
JSON API User Plus Plugin has been updated today with version 1.2. Details of the added & updated endpoints are following:
Version 1.2.0
- Added ‘new_post’, ‘update_post’, ‘delete_post’ endpoints.
- Updated ‘generate_auth_cookie’ to include ‘cookie_name’ value in the response.
Method: new_post
Required argument
- cookie – for user authentication
- nonce – available from the get_nonce method (call with vars controller=userplus and method=new_post)
- status – sets the post status (“draft” or “publish”)
- title – the post title
- content – the post content
Optional arguments
- categories – a comma-separated list of categories (URL slugs)
- tags – a comma-separated list of tags (URL slugs)
- attachment – upload field will cause an attachment to be stored with new post with image set as featured thumbnail
Example
URL to POST values: http://localhost/api/userplus/new_post/
Note: User must have capability to add post. Change user role if needed.
Method: update_post
Required argument
- cookie – for user authentication
- post_id – post ID to be updated
- nonce – available from the get_nonce method (call with vars controller=userplus and method=update_post)
Optional arguments
- status – sets the post status (“draft” or “publish”)
- title – the post title
- content – the post content
- categories – a comma-separated list of categories (URL slugs)
- tags – a comma-separated list of tags (URL slugs)
- post_media – to delete all previously attached images from post, pass value ‘delete’
- attachment – upload field will cause an attachment to be stored with new post with image set as featured thumbnail. Previously uploaded images will still be attached to post. Old media can be deleted by sending post_media=delete
Example
URL to POST values: http://localhost/api/userplus/update_post/
Note: User must have capability to update post. Change user role if needed.
Method: delete_post
Required argument
- cookie – for user authentication
- post_id – post ID to delete
- nonce – available from the get_nonce method (call with vars controller=userplus and method=delete_post)
Optional arguments
- post_media – to delete all previously attached images from post, pass value ‘delete’
- force_delete – if set to ‘true’, it will delete the post bypassing the WordPress trash.
Example
URL to POST values: http://localhost/api/userplus/delete_post/
Note: User must have capability to delete post. Change user role if needed.
Please refer to the documentation for more details.
Hope that helps. Cheers!