package main import ( "encoding/json" "flag" "fmt" "io/ioutil" "net/http" "os" ) var ( ids string = "" TOKEN string = "" ) type User struct { Response []struct { FirstName string `json:"first_name"` HomePhone string `json:"home_phone"` LastName string `json:"last_name"` MobilePhone string `json:"mobile_phone"` ID int `json:"id"` } `json:"response"` } func init() { flag.StringVar(&ids, "u", ids, "user ids") flag.StringVar(&TOKEN, "t", TOKEN, "token") flag.Parse() } func Request(params string) []byte { url := "https://api.vk.com/method/users.get?user_ids=" + params + "&fields=contacts&v=5.44&access_token=" + TOKEN client := http.Client{} r, err := http.NewRequest("GET", url, nil) if err != nil { panic(err) } resp, err := client.Do(r) defer resp.Body.Close() if err != nil { panic(err) } body, err := ioutil.ReadAll(resp.Body) if err != nil { panic(err) } return body } func main() { if ids == "" || TOKEN == "" { fmt.Printf("Usage: %s -t -u \n", os.Args[0]) os.Exit(1) } req := Request(ids) resp := User{} json.Unmarshal(req, &resp) for _, user := range resp.Response { fmt.Printf("FirstName: %s\nLastName: %s\nID:%d\nPhone:%s\n#####################\n\n", user.FirstName, user.LastName, user.ID, user.MobilePhone) } }