简介 WordPress v4.4以后,已经内置了WP REST API。 接口文档:https://developer.wordpress.org/rest-api/ The WordPress REST API provides an interface for applications to interact with your WordPress site by sending and r […]
2023-05-04 210 VTHEME
WordPress 自带的 RESTful API 内置的身份验证方法是 Cookie Authentication ,登录仪表板时,会生成cookie。为了防止CSRF,需要在请求的地址后面,加上一个 nonce 参数“_wpnonce”。 CSRF请参考:https://javascript.net.cn/article?id=683 nonce生成,参考:https://verytheme. […]
2023-05-04 188 VTHEME
一,添加路由 add_action( 'rest_api_init', function () { register_rest_route( 'rangtuo/v1', '/author/(?P<id>\d+)', array( 'methods' => 'GET', 'callback' => 'test_callback', )); }); function test_ […]
2023-05-04 161 VTHEME
在开发 WordPress RESTful API 时,用来返回结果集。可以修改 http 请求的状态码。 官方文档: http://developer.wordpress.org/rest-api/extending-the-rest-api/adding-custom-endpoints/ http://developer.wordpress.org/reference/classes/wp_ […]
2021-07-25 812 VTHEME
WordPress 5.6 以后内置了RESTful API,并且建议用户一定不要关闭,否则会影响WordPress后台的某些功能。调用某些接口的时候,会提示 Cookie Authentication 是 WordPress 内置的身份验证方法。登录仪表板时,会生成cookie。 但是,REST API包含一种称为nonce的技术来避免CSRF的问题。 使用内置Javascript API的开发 […]
2021-07-09 937 VTHEME
登录
注册
重置密码