VK API wrapper in golang
Installing
go get github.com/himidori/golang-vk-api
Authorizing using username and password
client, err := vkapi.NewVKClient(vkapi.DeviceIPhone, "username", "password")
Authorizing using access token
client, err := vkapi.NewVKClientWithToken("token", nil)
Listening longpoll events
client.AddLongpollCallback("msgin", func(m *vkapi.LongPollMessage) {
fmt.Printf("new message received from uid %d\n", m.UserID)
})
client.AddLongpollCallback("msgdel", func(m *vkapi.LongPollMessage) {
fmt.Printf("message %d was deleted\n", m.MessageID)
})
client.AddLongpollCallback("msgout", func(m *vkapi.LongPollMessage) {
fmt.Printf("sent message to uid %d\n", m.UserID)
})
client.AddLongpollCallback("msgread", func(m *vkapi.LongPollMessage) {
fmt.Printf("message %d was read\n", m.MessageID)
})
client.AddLongpollCallback("msgonline", func(m *vkapi.LongPollMessage) {
fmt.Printf("user %d is now online\n", m.UserID)
})
client.ListenLongPollServer()