generated from oklookat/gostarter
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
3_validatePhoneConfirm.go
72 lines (62 loc) · 1.7 KB
/
3_validatePhoneConfirm.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
package vkmauth
import (
"context"
"fmt"
)
func validatePhoneConfirm(
ctx context.Context,
deviceId,
code,
phone,
anonToken,
sid string,
) (*validatePhoneConfirmResponse, error) {
form := map[string]string{
"access_token": anonToken,
"code": code,
"phone": phone,
"device_id": deviceId,
"sak_version": _sakVersion,
"can_skip_password": "0", // what if 1?
"v": _apiVersion,
"api_id": _apiId,
"sid": sid,
}
result := &validatePhoneConfirmResponse{}
cl := getClient()
resp, err := cl.R().
SetFormUrlMap(form).
SetResult(result).
Post(ctx, _vkApiUrl+"/method/auth.validatePhoneConfirm")
if err != nil {
return nil, err
}
if result.IsError() {
return nil, result
}
if resp.IsError() {
return nil, newError(fmt.Sprintf("%d", resp.StatusCode), "validatePhoneConfirm resp.IsError()")
}
return result, err
}
type validatePhoneConfirmResponse struct {
ResponseWithError
Response struct {
Sid string `json:"sid"`
ProfileExist bool `json:"profile_exist"`
Profile struct {
FirstName string `json:"first_name"`
Has2Fa bool `json:"has_2fa"`
LastName string `json:"last_name"`
Photo200 string `json:"photo_200"`
Phone string `json:"phone"`
CanUnbindPhone bool `json:"can_unbind_phone"`
} `json:"profile"`
SignupFields []string `json:"signup_fields"`
SignupRestrictedSubject string `json:"signup_restricted_subject"`
SignupParams struct {
PasswordMinLength int `json:"password_min_length"`
BirthDateMax string `json:"birth_date_max"`
} `json:"signup_params"`
} `json:"response"`
}