I want to create mobile app for one wordpress website. I have integrated the wordpress json plugin. I'm not sure where I can find service for user registration and login. Please advice.
相关问题
- Jackson Deserialization not calling deserialize on
- How to maintain order of key-value in DataFrame sa
- StackExchange API - Deserialize Date in JSON Respo
- Display product ACF field value in Woocommerce tra
- Adding a custom button after add to cart button in
1.Paste Following code in your themes
function.php
file.2.Make sure that
WP-REST-API
plugin Should be installed on wordpress siteThen your API will be created as
Try it with Postman You will get
200
as a response anduser info
I was able to figure out both login and signup using @Salam El-Bannas' link, in case any one still needs this here you go:
All through you need two plugins to get the job done:
WordPress JSON API plugin
and
JSON API User
For registration of users: You need nonce ID which will be a part of the registration params in the GET url process (this is provided by the plugins). Read @Salam El-Bannas' link for more understanding. The methodology i used in android was that immediately the page loads I block the UI with "Connecting..." message while in the background am getting the nonce ID once its done the UI Blocking disappears and the nonce ID is added to a special non-editable EditText field created for the nonce ID, the user then enters his/her required credentials and I authenticate that its valid before connecting to the server using the nonce ID i got. the result from the server is JSON so i can handle the rest in android code using volley and GSON.
For Login of users: You only need cookies ID generated by the plugin eg in my case
http://localhost/mylocalhost/my_api_base/user/generate_auth_cookie/?insecure=cool&email=xxx@xdfer.org&password=xxxv678
and the result was this json;
{"status":"ok","cookie":"xxxx|1486130938|Ot6yAX7iU773JnQ2zfE8sdmjt09LhHqDKSYBqtekuha|7fe58a35ab9f260c9bced9148f5cf9ae3ab56c16d7d9ce3b2db7da651d4d937d","cookie_name":"wordpress_logged_in_4132d8131ebbc6760d21627637bd4b20","user":{"id":1,"username":"administrator","nicename":"administrator","email":"xxx@xdfer.org","url":"","registered":"2016-11-02 17:46:19","displayname":"xxxx","firstname":"","lastname":"","nickname":"xxxxwedds","description":"","capabilities":"","avatar":null}}
then you have to read this nice tutorial to use the resulting JSON in android (that's if you are new to android login) else just use your discretion.
Its really really really simple and interesting once you follow my lined up process.
To register a user this will show you exactly how to register one on the database by simply calling a url and adding data to it using GET Method. Now to do so from a mobile app you just have to make an http request to a url containing all the data required for the user. This will show you how to make a request from Android.
This is just for registering users there will be another plugin JSON APi Auth used in order to login a user.
These are the basics since I don't have much time now, when I do, I will provide full details and example. But for now this shall do it