作者 唐旭辉

调整

@@ -65,3 +65,55 @@ func (p UserCreate) Format() map[string]string { @@ -65,3 +65,55 @@ func (p UserCreate) Format() map[string]string {
65 func (p UserCreate) GetPath() string { 65 func (p UserCreate) GetPath() string {
66 return "/user/create.action" 66 return "/user/create.action"
67 } 67 }
  68 +
  69 +type UserRefreshToken struct {
  70 + Accid string
  71 +}
  72 +
  73 +var (
  74 + _ ImParam = UserRefreshToken{}
  75 +)
  76 +
  77 +func (p UserRefreshToken) Format() map[string]string {
  78 + return map[string]string{
  79 + "accid": p.Accid,
  80 + }
  81 +}
  82 +
  83 +func (p UserRefreshToken) GetPath() string {
  84 + return "/user/refreshToken.action"
  85 +}
  86 +
  87 +type UserUpdateUinfo struct {
  88 + Accid string
  89 + Name string //这边网易云要有昵称以手机号码为昵称
  90 + Icon string //icon默认头像
  91 + Sign string //签名
  92 + Email string
  93 + Birth string
  94 + Mobile string
  95 + Gender int //0未知,1男,2女
  96 + Ex string //扩展字段
  97 +}
  98 +
  99 +var (
  100 + _ ImParam = UserUpdateUinfo{}
  101 +)
  102 +
  103 +func (u UserUpdateUinfo) Format() map[string]string {
  104 + return map[string]string{
  105 + "accid": u.Accid,
  106 + "name": u.Name,
  107 + "icon": u.Icon,
  108 + "sign": u.Sign,
  109 + "email": u.Email,
  110 + "birth": u.Birth,
  111 + "mobile": u.Mobile,
  112 + "gender": fmt.Sprintf("%d", u.Gender),
  113 + "ex": u.Ex,
  114 + }
  115 +}
  116 +
  117 +func (u UserUpdateUinfo) GetPath() string {
  118 + return "/user/refreshToken.action"
  119 +}
@@ -3,6 +3,7 @@ package im @@ -3,6 +3,7 @@ package im
3 import ( 3 import (
4 "crypto/sha1" 4 "crypto/sha1"
5 "encoding/hex" 5 "encoding/hex"
  6 + "encoding/json"
6 "io/ioutil" 7 "io/ioutil"
7 "math/rand" 8 "math/rand"
8 "net/http" 9 "net/http"
@@ -68,3 +69,12 @@ func (i ImClient) httpDo(path string, posts map[string]string) ([]byte, error) { @@ -68,3 +69,12 @@ func (i ImClient) httpDo(path string, posts map[string]string) ([]byte, error) {
68 func (i ImClient) Call(param ImParam) ([]byte, error) { 69 func (i ImClient) Call(param ImParam) ([]byte, error) {
69 return i.httpDo(param.GetPath(), param.Format()) 70 return i.httpDo(param.GetPath(), param.Format())
70 } 71 }
  72 +
  73 +//ParseUserCreateResult 解析返回值
  74 +func ParseUserCreateResult(v []byte) (*UserCreateResult, error) {
  75 + var result *UserCreateResult
  76 + if err := json.Unmarshal(v, result); err != nil {
  77 + return nil, err
  78 + }
  79 + return result, nil
  80 +}