Wordpress JSON REST API Tutorial for beginners(#13) How can Register a REST API route in wordpress

preview_player
Показать описание
In this video we have discussed about,

How can Register a REST API route in wordpress

register_rest_route( string $namespace, string $route, array $args = array(), bool $override = false )

add_action("rest_api_init","owt_first_custom_route");

function owt_first_custom_route(){

register_rest_route("owt/v1","/simple",array(
"method"="GET",
"callback"="call_me_simple_route"
));

}

function call_me_simple_route(){
global $wpdb;
$users_list = $wpdb-get_results(
$wpdb-prepare(
"SELECT * from ".$wpdb-prefix."users ORDER by ID desc",""
),ARRAY_A
);
//return array("status"=1,"message"="Simple Route has been called","method"="GET");
return $users_list;
}


Get All Post

Delete Post

GITHub Link:

Documentation Study:

SOCIAL :
===============

Also you can learn Wordpress Custom
===============

Tags
===================
Wordpress JSON REST API Development tutorial for beginners step by step,
Wordpress JSON REST API Development tutorial,
Wordpress JSON REST API Development tutorial in hindi,
Wordpress JSON REST API Development,
Wordpress JSON REST API Development for beginners,
Wordpress JSON REST API Development tutorial for beginners,
Wordpress JSON REST API Development tutorial for beginners,
Wordpress JSON REST API Development tutorials guide,
learn Wordpress JSON REST API Development framework step by step,
learn Wordpress JSON REST API Development from scratch,
WordPress JSON REST API,
WordPress JSON REST API Development for Beginners: Developing a JSON REST API,
Get started with the WordPress JSON REST API,
The WordPress JSON REST API,
online web tutor,
profotech solutions,

Thanks
Online Web Tutor
Keep learning and Sharing :)
Рекомендации по теме
Комментарии
Автор

hers what i learned.
Oki, basically, So

darickquinto
Автор

Hello boss,
hope are you doing good,

I am working on some project of wordpress API more then 6 months now. I go through your playlist I found that you talk about on 3 points

1) json plugin (nonce value generate after login ) = for logged in user.

2) Basic authentication plugin (we pass header with, Basic base_64encode value of username and password with basic auth)== security wise its not good because I am using AJAX and header is visible in java script file. we can easily decode base 64 from online websites.

3) Adding Custom Routes to the WordPress REST API (both login and logout user)

I am using third approach passing using user_id and delete some meta_value. (I am not logged in on site so no nonce value)

If anyone know the routes url of custom route and parameters he can just open postman and hit api with parameters can misuse that,

For custom routes how we can securely pass authentication and headers.

I don’t have any knowledge about API security.

Best regards,

shubhamsharma-ucxo
visit shbcf.ru