func RequestAuthentication(host string, username string, password string) (map[string]interface{}, error) {
	var result map[string]interface{}

	resp, err := http.PostForm(host+"login/token.php?service=moodle_mobile_app", url.Values{
		"username": {username},
		"password": {password},
	})
	if err != nil {
		log.Println(err)
		return result, err
	}

	defer resp.Body.Close()
	body, err := ioutil.ReadAll(resp.Body)

	if err != nil {
		log.Println(err)
		return result, err
	}

	// Get the content
	err = json.Unmarshal([]byte(body), &result)

	return result, err
}
// RequestAuthentication requests Moodle for a user's token
// Resquest: <host>/login/token.php?service=moodle_mobile_app
// Body: username: username, password: password
// Returns the user's token in the Moodle or an error code if Moodle Web
// Services aren't allowed in the server
// NOTE: If a Moodle service is https:// and the user types http://, Moodle will
// return an error saying that the username wasn't provided!
RequestAuthentication requests Moodle for a user's token
Resquest: /login/token.php?service=moodle_mobile_app
Body: username: username, password: password
Returns the user's token in the Moodle or an error code if Moodle Web
Services aren't allowed in the server
NOTE: If a Moodle service is https:// and the user types http://, Moodle will
return an error saying that the username wasn't provided!
// RequestAuthentication requests Moodle for a user ' s token // Resquest : <host > / login / token . php?service = moodle_mobile_app // Body : username : username password : password // Returns the user ' s token in the Moodle or an error code if Moodle Web // Services aren ' t allowed in the server // NOTE : If a Moodle service is https : // and the user types http : // Moodle will // return an error saying that the username wasn ' t provided!
func RequestAuthentication(host string, username string, password string) (map[string]interface{}, error) {
	var result map[string]interface{}
	resp, err := http.PostForm(host+"login/token.php?service=moodle_mobile_app", url.Values{
		"username": {username},
		"password": {password},
	})
	if err != nil {
		log.Println(err)
		return result, err
	}
	defer resp.Body.Close()
	body, err := ioutil.ReadAll(resp.Body)
	if err != nil {
		log.Println(err)
		return result, err
	}
	err = json.Unmarshal([]byte(body), &result)
	return result, err
}
func RequestAuthentication ( host string , username string , password string ) ( map [ string ] interface { } , error ) { var result map [ string ] interface { } resp , err := http . PostForm ( host + " " , url . Values { " " : { username } , " " : { password } , } ) if err != nil { log . Println ( err ) return result , err } defer resp . Body . Close ( ) body , err := ioutil . ReadAll ( resp . Body ) if err != nil { log . Println ( err ) return result , err } err = json . Unmarshal ( [ ] byte ( body ) , & result ) return result , err }
RequestAuthentication requests Moodle for a user's token
Resquest: /login/token.php?service=moodle_mobile_app
Body: username: username, password: password
Returns the user's token in the Moodle or an error code if Moodle Web
Services aren't allowed in the server
NOTE: If a Moodle service is https:// and the user types http://, Moodle will
return an error saying that the username wasn't provided!
RequestAuthentication requests Moodle for a user ' s token Resquest : / login / token . php?service = moodle_mobile_app Body : username : username password : password Returns the user ' s token in the Moodle or an error code if Moodle Web Services aren ' t allowed in the server NOTE : If a Moodle service is https : // and the user types http : // Moodle will return an error saying that the username wasn ' t provided!
// Get the content