为了统一用户登录,特开发Uclient插件
先在配置文件对UC参数进行配置好才能使用
1、导入类
import org.jkas.uclient.Uclient;
2、实例化
Uclient()//所有参数自动从配置文件读取
void setIp(String ip)//设置客户端用户来源IP
void setType(int type)//接口方式,1为数据库接口,2为网络接口
void setAppid(String appid)//设置appid,由用户中心分配获得
void setAuthkey(String authkey)//设置通信密码
void setPrikey(String prikey)//设置通信密钥
int ver();//uclient版本号
String verName();//uclient版本名称
3、登录
HashMap<String,String> login(String username,String password)//传入用户名密码
返回值(json):
{"code":-4,"msg":"invalid access"}//无效访问
{"code":-1,"msg":"invalid username"}//用户名无效
{"code":7,"msg":"wrong password"}//密码不正确
{"code":2,"msg":"username don't exists"}//用户不存在
{"code":1,"msg":"success","uid":"uid","user_id":"user_id","username":"username"}//登录成功,返回用户信息
4、注册
HashMap<String,String> register(String username,String password)//用户名和密码
HashMap<String,String> register(String username,String password,String mobile)//用户名、密码和手机号
HashMap<String,String> register(String username,String password,String mobile,String email)//用户名、密码、手机号和邮箱
返回值(json):
{"code":-4,"msg":"invalid access"}//无效访问
{"code":-1,"msg":"invalid username"}//用户名无效
{"code":3,"msg":"mobile exists"}//手机号已经存在
{"code":5,"msg":"wrong
mobile"}//手机号码格式不正确
{"code":4,"msg":"email
exists"}//邮件地址已经存在
{"code":6,"msg":"wrong
email"}//邮件格式不正确
{"code":-2,"msg":"failed"}//注册失败
{"code":2,"msg":"username
exists"}//用户名已经存在
{"code":1,"msg":"success","uid":"nuid"}//注册成功
5、更新
HashMap<String,String> modify(String username,String newusername)
HashMap<String,String> modify(String username,String password,String oldpassword)
HashMap<String,String> modify(String username,String password,String oldpassword,String mobile)
HashMap<String,String> modify(String username,String password,String oldpassword,String mobile,String email)
HashMap<String,String> modify(String username,String password,String oldpassword,String mobile,String email,boolean force)//force为true时,强制修改,不用校验旧密码
HashMap<String,String> modify(String username,String newusername,String password,String oldpassword,String mobile,String email,boolean force)//force为true时,强制修改,不用校验旧密码
返回值 :
{"code":-4,"msg":"invalid access"}//无效访问
{"code":2,"msg":"username not
found"}
{"code":3,"msg":"mobile exists"}
{"code":5,"msg":"wrong
mobile"}
{"code":4,"msg":"email exists"}
{"code":6,"msg":"wrong
email"}
{"code":8,"msg":"wrong old
password"}
{"code":-2,"msg":"faild"}
{"code":1,"msg":"success"}
6、删除
HashMap<String,String> drop(String username)
返回值(json):
{"code":-4,"msg":"invalid access"}//无效访问
{"code":-2,"msg":"failed"}
{"code":1,"msg":"success"}
7、查询
HashMap<String,String> check(String username)
HashMap<String,String> check(String value,String column) //value:值 column :列名(只能是username,mobiel,email 之一)
返回值:
{"code":-1,"msg":"invalid
username"}
{"code":5,"msg":"wrong mobile"}
{"code":6,"msg":"wrong
email"}
{"code":-3,"msg":"invalid
check"}
{"code":1,"msg":"success","uid":uid,"username":"username","mobile":"mobile","email":"email"}
{"code":2,"msg":"column
don't exists"}
{"code":0,"msg":"unknown error"}