FOR JSON API登录
方法:generate_auth_cookie
首先得到该随机数:http://localhost/api/get_nonce/?controller=user&method=generate_auth_cookie
然后生成的Cookie:http://localhost/api/user/generate_auth_cookie/?username=john&password=PASSWORD-HERE
方法:validate_auth_cookie 它需要 '饼干' 变种。
http://localhost/api/user/validate_auth_cookie/?cookie=admin|43089754375034fjwfn39u8
所以当用户发送req。当你需要创建nonce然后gen时登录。 auth cookie等。如果一切正常,请登录到用户。并将其保存到您的网站。所以一旦用户点击注销。会话将被删除。
您也可以从这里设置会话
产生饼干1分钟:http://localhost/api/user/generate_auth_cookie/?username=john&password=PASSWORD-HERE&seconds=60
60来1分钟。
细节
https://wordpress.org/plugins/json-api-user/other_notes/
OR
TRY - WP REST API V2
http://v2.wp-api.org/
立即下载插件并安装它。
https://wordpress.org/plugins/json-rest-api/
只是在你的网站URL的末尾键入/wp-json/wp/v2/posts
,你会得到所有的文章。
用于获取所有后
www.mysite.com/wp-json/wp/v2/posts
对于搜索功能 - 搜索测试后从这个链接http://v2.wp-api.org/reference/posts/
注意,效果最好使用最新版本WP的
/wp-json/wp/v2/posts?filter[s]=test
更多细节
所以用这个你可以很容易我会得到张贴页等
我怎么能在jQuery中获取cookie var? –
你需要打电话给url,作为回应,你会得到cookie var。 –