vk

package
v0.0.0-...-f5986cb Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 21, 2020 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Overview

Package vk provides base VK API functionality such as auth.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type API

type API struct {
	Token string
	// contains filtered or unexported fields
}

API is a VK API wrapper.

func FromCode

func FromCode(code string, settings Settings) (*API, error)

FromCode returns "API" wrapper if code is correct, error otherwise.

func FromToken

func FromToken(token string, settings Settings) API

FromToken returns "API" wrapper with provided token.

func (API) Call

func (api API) Call(method string, body url.Values) (io.ReadCloser, error)

Call is calling provided VK API "method" with provided body urlencoded params. It uses access token and API version from wrapper object.

func (API) User

func (api API) User() (*User, error)

User returns access_token user information.

func (API) UserID

func (api API) UserID() int

UserID returns user id from access token response if API was retrieved using "FromCode", -1 otherwise.

type Settings

type Settings struct {
	ClientID     string
	ClientSecret string
	RedirectURI  string
	Version      string
}

Settings is a VK app and API settings.

type User

type User struct {
	ID        int    `json:"id"`
	FirstName string `json:"first_name"`
	LastName  string `json:"last_name"`
	Photo     string `json:"photo_400_orig"`
}

User is a wrapper for VK API user object.

func (User) FullName

func (user User) FullName() string

FullName returns full VK user name.

type UserResponse

type UserResponse struct {
	Response *[]User `json:"response"`
	Error    *string `json:"error"`
}

UserResponse is a wrapper for "users.get" method response of an VK API.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL