1.登录
var model = api.require('model');
model.config({
appId:'xxx',
appKey: 'xxx',
host: 'https://d.apicloud.com'
});
var user = api.require('user');
user.login({
username: '123',
password: '123'
}, function( ret, err ) {
if( ret ){
alert( JSON.stringify( ret) );
}else{
alert( JSON.stringify( err) );
}
});
2.注册
var model = api.require('model');
model.config({
appId:'xxx',
appKey: 'xxx',
host: 'https://d.apicloud.com'
});
var user = api.require('user');
user.register({
username: 'test',
password: 'test',
email: 'test@apicloud.com'
}, function( ret, err ) {
if( ret ){
alert( JSON.stringify( ret) );
}else{
alert( JSON.stringify( err) );
}
});
3.登出
var model = api.require('model');
model.config({
appId:'xxx',
appKey: 'xxx',
host: 'https://d.apicloud.com'
});
var user = api.require('user');
user.logout(function(ret, err){
if( ret ){
alert( JSON.stringify( ret) );
}else{
alert( JSON.stringify( err) );
}
});
4.修改密码
var model = api.require('model');
model.config({
appId:'xxx',
appKey: 'xxx',
host: 'https://d.apicloud.com'
});
var user = api.require('user');
user.login({
username: '123',
password: '123456'
}, function( ret, err ) {
if( ret ){
alert( JSON.stringify( ret) );
}else{
alert( JSON.stringify( err) );
}
});
user.updatePassword({
password: '123456'
}, function(ret, err) {
if( ret ){
alert( JSON.stringify( ret) );
}else{
alert( JSON.stringify( err) );
}
});
本文转自TBHacker博客园博客,原文链接:http://www.cnblogs.com/jiqing9006/p/5917222.html,如需转载请自行联系原作者