Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/himidori/golang-vk-api
Methods for VK API
https://github.com/himidori/golang-vk-api
golang vk-api
Last synced: 3 months ago
JSON representation
Methods for VK API
- Host: GitHub
- URL: https://github.com/himidori/golang-vk-api
- Owner: himidori
- License: gpl-3.0
- Created: 2017-11-08T19:03:39.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2022-04-10T19:55:57.000Z (almost 3 years ago)
- Last Synced: 2024-09-27T05:01:58.543Z (4 months ago)
- Topics: golang, vk-api
- Language: Go
- Size: 142 KB
- Stars: 52
- Watchers: 8
- Forks: 26
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# VK API wrapper in golang
## Installing
```
go get github.com/himidori/golang-vk-api
```## Authorizing using username and password
```go
client, err := vkapi.NewVKClient(vkapi.DeviceIPhone, "username", "password", true)
```## Authorizing using access token
```go
client, err := vkapi.NewVKClientWithToken("token", nil, true)
```## Listening longpoll events
```go
// listening received messages
client.AddLongpollCallback("msgin", func(m *vkapi.LongPollMessage) {
fmt.Printf("new message received from uid %d\n", m.UserID)
})// listening deleted messages
client.AddLongpollCallback("msgdel", func(m *vkapi.LongPollMessage) {
fmt.Printf("message %d was deleted\n", m.MessageID)
})// listening sent messages
client.AddLongpollCallback("msgout", func(m *vkapi.LongPollMessage) {
fmt.Printf("sent message to uid %d\n", m.UserID)
})// listening read messages
client.AddLongpollCallback("msgread", func(m *vkapi.LongPollMessage) {
fmt.Printf("message %d was read\n", m.MessageID)
})// listening users online
client.AddLongpollCallback("msgonline", func(m *vkapi.LongPollMessage) {
fmt.Printf("user %d is now online\n", m.UserID)
})// starting
client.ListenLongPollServer()
```