作者 唐旭辉

调整

... ... @@ -65,3 +65,55 @@ func (p UserCreate) Format() map[string]string {
func (p UserCreate) GetPath() string {
return "/user/create.action"
}
type UserRefreshToken struct {
Accid string
}
var (
_ ImParam = UserRefreshToken{}
)
func (p UserRefreshToken) Format() map[string]string {
return map[string]string{
"accid": p.Accid,
}
}
func (p UserRefreshToken) GetPath() string {
return "/user/refreshToken.action"
}
type UserUpdateUinfo struct {
Accid string
Name string //这边网易云要有昵称以手机号码为昵称
Icon string //icon默认头像
Sign string //签名
Email string
Birth string
Mobile string
Gender int //0未知,1男,2女
Ex string //扩展字段
}
var (
_ ImParam = UserUpdateUinfo{}
)
func (u UserUpdateUinfo) Format() map[string]string {
return map[string]string{
"accid": u.Accid,
"name": u.Name,
"icon": u.Icon,
"sign": u.Sign,
"email": u.Email,
"birth": u.Birth,
"mobile": u.Mobile,
"gender": fmt.Sprintf("%d", u.Gender),
"ex": u.Ex,
}
}
func (u UserUpdateUinfo) GetPath() string {
return "/user/refreshToken.action"
}
... ...
... ... @@ -3,6 +3,7 @@ package im
import (
"crypto/sha1"
"encoding/hex"
"encoding/json"
"io/ioutil"
"math/rand"
"net/http"
... ... @@ -68,3 +69,12 @@ func (i ImClient) httpDo(path string, posts map[string]string) ([]byte, error) {
func (i ImClient) Call(param ImParam) ([]byte, error) {
return i.httpDo(param.GetPath(), param.Format())
}
//ParseUserCreateResult 解析返回值
func ParseUserCreateResult(v []byte) (*UserCreateResult, error) {
var result *UserCreateResult
if err := json.Unmarshal(v, result); err != nil {
return nil, err
}
return result, nil
}
... ...