diff --git a/vk-to-smtp.go b/vk-to-smtp.go index a500e72..14398d5 100644 --- a/vk-to-smtp.go +++ b/vk-to-smtp.go @@ -24,12 +24,12 @@ import ( */ func main() { - // Get token and group id from ENV + // Init: Get token and group id from ENV token := os.Getenv("vktoken") - groupId, err := strconv.Atoi(os.Getenv("vkgroupid")) - if err != nil { - log.Fatal(err) - } + //groupId, err := strconv.Atoi(os.Getenv("vkgroupid")) + //if err != nil { + // log.Fatal(err) + //} // Init VK vk := api.NewVK(token) @@ -37,8 +37,9 @@ func main() { // Fill params for wallGet wallGetParams := params.NewWallGetBuilder() wallGetParams.Count(10) + wallGetParams.Domain("podvalsound") wallGetParams.Extended(true) - wallGetParams.OwnerID(groupId) + //wallGetParams.OwnerID(groupId) // Do WallGet posts, err := vk.WallGet(wallGetParams.Params) @@ -61,7 +62,22 @@ func main() { fmt.Println(ownerName[0].Name) fmt.Println("Text:") fmt.Println(item.Text) + fmt.Println("Attach: ") + // проходимся по аттачам если есть + if item.Attachments != nil { + //fmt.Println(item.Attachments) + for _, attach := range item.Attachments { + // если это фото - вытаскиваем урл + photosObj := attach.Photo + if photosObj.Sizes != nil { + for _, photoSizeObj := range photosObj.Sizes { + if photoSizeObj.Type == "y" { + fmt.Println(photoSizeObj.URL) + } + } + } + } + } } } - }