Working on Rest API and OAuth is very interesting

https://app.gitbook.com/@wordpress-lionel/s/project/rest-api-create-update-or-delete-posts-using-basic-auth-and-http-api-ok

OAuth Information

https://developer.wordpress.com/apps/73691arrow-up-right

Client ID	73691
Client Secret	JGSUmvoQRnlFCJzYdTY8UWdVnRkCBmlHl7Bz338WaRHCLDMDxUVthCDW675ln7TS
Redirect URLs	https://www.google.com
Javascript Origins	
Type	Web
Request token URL	https://public-api.wordpress.com/oauth2/token
Authorize URL	https://public-api.wordpress.com/oauth2/authorize
Authenticate URL	https://public-api.wordpress.com/oauth2/authenticate

Working on Rest API and OAuth is very interesting.

WordPress merged Rest API support into the core in WordPress 4.7 “Vaughan”arrow-up-right check out the Rest API Merge Proposalarrow-up-right.

In this post, I’m creating the post on my site https://maheshwaghmare.com/arrow-up-right though rest API and OAuth.

Top ↑arrow-up-right

#Let’s Try it Step by Steparrow-up-right Let’s Try it Step by Step

#Step 1: Step 1:

Create new app wordpress.com app from https://developer.wordpress.com/apps/new/arrow-up-right

OR

Do you already have an app then select existing app from https://developer.wordpress.com/apps/arrow-up-right

Top ↑arrow-up-right

#Step 2: Step 2:

Copy below code and add your app authentication details. After adding details you get and auth key.

Note: Keep grant_type as password. Its required!

  • username – Your website username.

  • password – Your website password.

  • client_id – Your App client ID.

  • client_id – Your App client ID.

Top ↑arrow-up-right

#Step 3: Step 3:

Use below function which return the auth key from your given app details.

Top ↑arrow-up-right

#Step 4: Step 4:

Add your new post details. Such as post title, post content etc. like below:

Top ↑arrow-up-right

#Step 5: Step 5:

Now, Simply call a function and pass the Auth key and post arguments.

Top ↑arrow-up-right

#Step 6: Step 6:

Here,

https://public-api.wordpress.com/rest/v1/sites/arrow-up-rightYOURSITEID/posts/new/

Replace YOURSITEID with your wordpress.com site ID.

To get it follow below quick simple steps:

It’ll show all your sites from WordPress.com. Check the below screenshot for reference.

Last updated