Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

github.com/justblender/vk-api

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/justblender/vk-api

  • v0.0.0-20170911191903-4c118d6a81f7
  • Source
  • Go
  • Socket score

Version published
Created
Source

vk-api

vk-api is a simple Golang package that provides tools to interact with VK API. Supports authentication using login and password or by passing an access token right into the app, as well as long polling. More features yet to come, probably gonna turn this into a full SDK.

Installation:

go get -t github.com/justblender/vk-api

Example:

package main

import (
    "os"
    "github.com/justblender/vk-api"
)

func main() {
    // Use either one of three types: NoAuthentication, DirectAuthentication and ClientCredentialsFlow
    client, err := vk_api.NewClient(vk_api.DirectAuthentication{
        Username: os.Getenv("username"),
        Password: os.Getenv("password"),
        Device: vk_api.ANDROID,
    })

    if err != nil {
        panic("Couldn't authenticate, sad!")
    }

    parameters := vk_api.RequestParameters{
        "user_id": 1,
        "message": "Pasha, bring back the wall!",
    }

    if _, err = client.Request("messages.send", parameters); err != nil {
        panic("Pasha couldn't bring back the wall")
    }
}

Using long polling:

// don't forget about the previously created Client!..
longPoll, err := client.NewLongPoll()
if err != nil {
    panic("Couldn't create a new LongPoll")
}

for {
    messages, err := longPoll.Poll()
    if err != nil {
        panic("Some bad error occurred")
    }

    for _, message := range messages {
        if message.HasFlag(vk_api.FLAG_CHAT) {
            fmt.Printf("New message from chat %d: %s\n", message.PeerID, message.Text)
        }
    }
}

FAQs

Package last updated on 11 Sep 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc