Connect API to login on Moodle

Connect API to login on Moodle

by Trianto Aridono -
Number of replies: 0
kindly help with this one.

I have some project to connect Moodle using API from client, login data to get from server FLP database, not from Moodle. I still don't understand how to install this API into Moodle. if i am not wrong we can write on moodlelib.php, i don't know.

here the API from client must be set on moodle:

1. Generate Token
https://vps.sample.com/generatetoken/api/login
Input Post
    username = admin
    password = admini123
Output Api
    {
        "status": true,
        "message": "",
        "key": "434b37b729bce958a0de4e3edb67c46f";
    }

2. Login Validation
https://vps.sample.com/sampleflp/api/1.0/login/validation
Header
    Authorization = 434b37b729bce958a0de4e3edb67c46f
    User = admin
Input Post
    username = user01
    password = pass01
Output Api
//If login Correct will get response:
{   "status": 1, 
    "message": "ok", 
    "data": [ 
        {   "userid": "user01", 
            "username": "usersatu" 
        }   
    ] 
}
//If login incorrect will get response:
{   "status": 0, 
    "message": "Data Not Found", 
    "code": "5001", 
    "data": { 
        "valid": 0 
    } 
}

Can you help me to give the guide to translate this into script in Moodle? I am very beginner for this things.

nb: Sorry for my bad English

Thanks.


Average of ratings: -