Skip to content
VK SDK | VKontakte wrapper for standalone apps
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
examples/sending-messages
.travis.yml
LICENSE
README.md
api.go
attachments.go
attachments_test.go
auth.go
client.go
client_test.go
errors.go
files.go
friends.go
groups.go
helpers.go
helpers_test.go
logo.png
longpoll.go
longpoll_test.go
messages.go
messages_test.go
scope.go
status.go
transport.go
users.go
wall.go
wall_test.go

README.md

VK API? GO!

Build Status GoDoc Language License

Work with Vkontakte API for StandAlone application on The Go Programming Language.

Usage / Installation

Installation

go get -u github.com/Dimonchik0036/vk-api

Example

Displays incoming messages. If this is a "/start", then a "Hello!" message will be sent.

package main

import (
	"github.com/dimonchik0036/vk-api"
	"log"
)

func main() {
	//client, err := vkapi.NewClientFromLogin("<username>", "<password>", vkapi.ScopeMessages)
	client, err := vkapi.NewClientFromToken("<access_token>")
	if err != nil {
	    log.Panic(err)
	}
	
	client.Log(true)

	if err := client.InitLongPoll(0, 2); err != nil {
		log.Panic(err)
	}

	updates, _, err := client.GetLPUpdatesChan(100, vkapi.LPConfig{25, vkapi.LPModeAttachments})
	if err != nil {
		log.Panic(err)
	}

	for update := range updates {
		if update.Message == nil || !update.IsNewMessage() || update.Message.Outbox(){
			continue
		}

		log.Printf("%s", update.Message.String())
		if update.Message.Text == "/start" {
			client.SendMessage(vkapi.NewMessage(vkapi.NewDstFromUserID(update.Message.FromID), "Hello!"))
		}

	}
}

Technical Details

  • API version 5.67.

Contributions

Chat me VK/Telegram for detailed steps.

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.