vkapi

package module
v0.0.0-...-e7e2fd6 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2020 License: MIT Imports: 18 Imported by: 1

README

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.

Documentation

Index

Examples

Constants

View Source
const (
	LangRU = "ru" //Russian
	LangUA = "ua" //Ukrainian
	LangBE = "be" //Belarusian
	LangEN = "en" //English
	LangES = "es" //Spanish
	LangFI = "fi" //Finnish
	LangDE = "de" //German
	LangIT = "it" //Italian
)
View Source
const (
	FriendFieldHints  = "hints"
	FriendFieldRandom = "random"
	FriendFieldMobile = "mobile"
	FriendFieldName   = "name"
)
View Source
const (
	LPMessageFlagUnread = 1 << iota
	LPMessageFlagOutBox
	LPMessageFlagReplied
	LPMessageFlagImportant
	LPMessageFlagChat
	LPMessageFlagFriends
	LPMessageFlagSpam
	LPMessageFlagDeleted
	LPMessageFlagFixed
	LPMessageFlagMedia
	LPMessageFlagHidden = 65536
)
View Source
const (
	LPModeAttachments   = 2
	LPModeExtendedEvent = 8
	LPModePts           = 32
	LPModeExtra         = 64
	LPModeRandomID      = 128
)
View Source
const (
	LPCodeMessageSetFlags      = 1
	LPCodeMessageAddFlags      = 2
	LPCodeMessageDelFlags      = 3
	LPCodeNewMessage           = 4
	LPCodeReadAllInboxMessage  = 6
	LPCodeReadAllOutboxMessage = 7
	LPCodeFriendOnline         = 8
	LPCodeFriendOffline        = 9
	LPCodeDialogDelFlags       = 10
	LPCodeDialogSetFlags       = 11
	LPCodeDialogAddFlags       = 12
	LPCodeDelAllMessage        = 13
	LPCodeChangeChat           = 51
	LPCodeTypingInDialog       = 61
	LPCodeTypingInChat         = 62
	LPCodeCall                 = 70
	LPCodeUnreadMessage        = 80
	LPCodeChangeNotification   = 114
)
View Source
const (
	LPPlatformUndefined = iota
	LPPlatformMobile
	LPPlatformIPhone
	LPPlatformIPad
	LPPlatformAndroid
	LPPlatformWPhone
	LPPlatformWindows
	LPPlatformWeb
)
View Source
const (
	// Full description at https://vk.com/dev/permissions
	ScopeFriends        = 2
	ScopePhotos         = 4
	ScopeAudio          = 8
	ScopeVideo          = 16
	ScopePages          = 128
	ScopeAddLink        = 256
	ScopeStatus         = 1024
	ScopeNotes          = 2048
	ScopeMessages       = 4096
	ScopeWall           = 8192
	ScopeAds            = 32768
	ScopeOffline        = 65536
	ScopeDocs           = 131072
	ScopeGroupsOrManage = 262144
	ScopeNotifications  = 524288
	ScopeStats          = 1048576
	ScopeEmail          = 4194304
	ScopeMarket         = 134217728

	ScopeAll = ScopeFriends | ScopePhotos | ScopeAudio | ScopeVideo | ScopePages | ScopeAddLink | ScopeStatus | ScopeNotes | ScopeMessages | ScopeWall | ScopeAds | ScopeOffline | ScopeDocs | ScopeGroupsOrManage | ScopeNotifications | ScopeStats | ScopeEmail | ScopeMarket
)
View Source
const (
	UserFieldAbout                  = "about"
	UserFieldActivities             = "activities"
	UserFieldBirthdayDate           = "bdate"
	UserFieldBlacklisted            = "blacklisted"
	UserFieldBlacklistedByMe        = "blacklisted_by_me"
	UserFieldBooks                  = "books"
	UserFieldCanPost                = "can_post"
	UserFieldCanSeeAllPosts         = "can_see_all_posts"
	UserFieldCanSeeAudio            = "can_see_audio"
	UserFieldCanSendFriendRequest   = "can_send_friend_request"
	UserFieldCanWritePrivateMessage = "can_write_private_message"
	UserFieldCarrer                 = "career"
	UserFieldCity                   = "city"
	UserFieldCommonCount            = "common_count"
	UserFieldConnections            = "connections"
	UserFieldContacts               = "contacts"
	UserFieldCounters               = "counters"
	UserFieldCountry                = "country"
	UserFieldCropPhoto              = "crop_photo"
	UserFieldDomain                 = "domain"
	UserFieldEducation              = "education"
	UserFieldFirstNameNom           = "first_name_nom"
	UserFieldFirstNameGen           = "first_name_gen"
	UserFieldFirstNameDat           = "first_name_dat"
	UserFieldFirstNameAcc           = "first_name_acc"
	UserFieldFirstNameIns           = "first_name_ins"
	UserFieldFirstNameAbl           = "first_name_abl"
	UserFieldFollowersCount         = "followers_count"
	UserFieldFriendStatus           = "friend_status"
	UserFieldGames                  = "games"
	UserFieldHasMobile              = "has_mobile"
	UserFieldHasPhoto               = "hasPhoto"
	UserFieldHomeTown               = "home_town"
	UserFieldInterests              = "interests"
	UserFieldIsFavorite             = "is_favorite"
	UserFieldIsFriend               = "is_friend"
	UserFieldIsHiddenFromFeed       = "is_hidden_from_feed"
	UserFieldLastNameNom            = "last_name_nom"
	UserFieldLastNameGen            = "last_name_gen"
	UserFieldLastNameDat            = "last_name_dat"
	UserFieldLastNameAcc            = "last_name_acc"
	UserFieldLastNameIns            = "last_name_ins"
	UserFieldLastNameAbl            = "last_name_abl"
	UserFieldLastSeen               = "last_seen"
	UserFieldMaidenName             = "maiden_name"
	UserFieldMilitary               = "military"
	UserFieldMovies                 = "movies"
	UserFieldMusic                  = "music"
	UserFieldNickname               = "nickname"
	UserFieldOccupation             = "occupation"
	UserFieldOnline                 = "online"
	UserFieldPersonal               = "personal"
	UserFieldPhoto50                = "photo_50"
	UserFieldPhoto100               = "photo_100"
	UserFieldPhoto200Orig           = "photo_200_orig"
	UserFieldPhoto200               = "photo_200"
	UserFieldPhoto400Orig           = "photo_400_orig"
	UserFieldPhotoId                = "photo_id"
	UserFieldPhotoMax               = "photo_max"
	UserFieldPhotoMaxOrig           = "photo_max_orig"
	UserFieldQuotes                 = "quotes"
	UserFieldRelatives              = "relatives"
	UserFieldRelation               = "relation"
	UserFieldSchool                 = "schools"
	UserFieldScreenName             = "screen_name"
	UserFieldSex                    = "sex"
	UserFieldSite                   = "site"
	UserFieldStatus                 = "status"
	UserFieldStatusAudio            = "status_audio"
	UserFieldTimezone               = "timezone"
	UserFieldTv                     = "tv"
	UserFieldUniversities           = "universities"
	UserFieldVerified               = "verified"
	UserFieldWallComments           = "wall_comments"
)
View Source
const (
	PostTypePost     = "post"
	PostTypeCopy     = "copy"
	PostTypeReply    = "reply"
	PostTypePostpone = "postpone"
	PostTypeSuggest  = "suggest"
)
View Source
const (
	ErrApiClientNotFound = "APIClient not found."
)

Variables

View Source
var UserFieldAll = []string{UserFieldAbout,
	UserFieldActivities,
	UserFieldBirthdayDate,
	UserFieldBlacklisted,
	UserFieldBlacklistedByMe,
	UserFieldBooks,
	UserFieldCanPost,
	UserFieldCanSeeAllPosts,
	UserFieldCanSeeAudio,
	UserFieldCanSendFriendRequest,
	UserFieldCanWritePrivateMessage,
	UserFieldCarrer,
	UserFieldCity,
	UserFieldCommonCount,
	UserFieldConnections,
	UserFieldContacts,
	UserFieldCounters,
	UserFieldCountry,
	UserFieldCropPhoto,
	UserFieldDomain,
	UserFieldEducation,
	UserFieldFirstNameNom,
	UserFieldFirstNameGen,
	UserFieldFirstNameDat,
	UserFieldFirstNameAcc,
	UserFieldFirstNameIns,
	UserFieldFirstNameAbl,
	UserFieldFollowersCount,
	UserFieldFriendStatus,
	UserFieldGames,
	UserFieldHasMobile,
	UserFieldHasPhoto,
	UserFieldHomeTown,
	UserFieldInterests,
	UserFieldIsFavorite,
	UserFieldIsFriend,
	UserFieldIsHiddenFromFeed,
	UserFieldLastNameNom,
	UserFieldLastNameGen,
	UserFieldLastNameDat,
	UserFieldLastNameAcc,
	UserFieldLastNameIns,
	UserFieldLastNameAbl,
	UserFieldLastSeen,
	UserFieldMaidenName,
	UserFieldMilitary,
	UserFieldMovies,
	UserFieldMusic,
	UserFieldNickname,
	UserFieldOccupation,
	UserFieldOnline,
	UserFieldPersonal,
	UserFieldPhoto50,
	UserFieldPhoto100,
	UserFieldPhoto200Orig,
	UserFieldPhoto200,
	UserFieldPhoto400Orig,
	UserFieldPhotoId,
	UserFieldPhotoMax,
	UserFieldPhotoMaxOrig,
	UserFieldQuotes,
	UserFieldRelatives,
	UserFieldRelation,
	UserFieldSchool,
	UserFieldScreenName,
	UserFieldSex,
	UserFieldSite,
	UserFieldStatus,
	UserFieldStatusAudio,
	UserFieldTimezone,
	UserFieldTv,
	UserFieldUniversities,
	UserFieldVerified,
	UserFieldWallComments}

Functions

func ApiURL

func ApiURL() (url url.URL)

ApiURL return standard url for interacting with server API.

func ConcatInt64ToString

func ConcatInt64ToString(numbers ...int64) string

ConcatInt64ToString concatenating array int64 and returns them as a string.

func ConcatValues

func ConcatValues(unite bool, values ...url.Values) (result url.Values)

ConcatValues concatenating values

func OAuthURL

func OAuthURL() (url url.URL)

OAuthURL return standard url for interacting with authentication server.

func Process

func Process(input io.Reader) (response *Response, err *Error)

Process processes the input data and returns a *Response in case of success.

Types

type APIClient

type APIClient struct {
	APIVersion  string
	AccessToken *AccessToken

	// HTTPS defines if use https instead of http. 1 - use https. 0 - use http.
	HTTPS string

	// Language define the language in which different data will be returned, for example, names of countries and cities.
	Language string
	// contains filtered or unexported fields
}

APIClient allows you to send requests to API server.

func NewApiClient

func NewApiClient() *APIClient

NewApiClient creates a new *APIClient instance.

func (*APIClient) Authenticate

func (api *APIClient) Authenticate(application Application) (err error)

Authenticate run authentication this APIClient from Application.

func (*APIClient) Do

func (api *APIClient) Do(request Request) (response *Response, error *Error)

Do sends a request to a specific endpoint with our request and returns response.

func (*APIClient) SetAccessToken

func (api *APIClient) SetAccessToken(token string)

SetAccessToken sets access token to APIClient.

func (*APIClient) SetHTTPClient

func (api *APIClient) SetHTTPClient(httpClient HTTPClient)

SetHTTPClient sets HTTPClient to APIClient.

func (*APIClient) SetLogger

func (api *APIClient) SetLogger(logger *log.Logger)

SetLogger sets logger to APIClient.

func (*APIClient) Values

func (api *APIClient) Values() (values url.Values)

Values returns values from this APIClient.

type AccessToken

type AccessToken struct {
	AccessToken      string `json:"access_token"`
	ExpiresIn        int64  `json:"expires_in"`
	UserID           int    `json:"user_id"`
	Error            string `json:"error"`
	ErrorDescription string `json:"error_description"`
	RedirectUri      string `json:"redirect_uri"`
	CaptchaSid       string `json:"captcha_sid"`
	CaptchaImg       string `json:"captcha_img"`
	ValidationType   string `json:"validation_type"` //2fa_sms 2fa_app
	PhoneMask        string `json:"phone_mask"`
}

AccessToken allows you to interact with API methods.

func Authenticate

func Authenticate(api *APIClient, app Application) (token *AccessToken, err error)

Authenticate authenticates *ApiClient through Application. If the outcome is successful, it returns a *AccessToken.

type Application

type Application struct {
	// GrantType - Authorization type, must be equal to `password`
	GrantType string `json:"grant_type"`

	// ClientID - ID of your application
	ClientID string `json:"client_id"`

	// ClientSecret - Secret key of your application
	ClientSecret string `json:"client_secret"`

	// Username - User username
	Username string `json:"username"`

	// Password - User password
	Password string `json:"password"`

	// Scope - Access rights required by the application
	Scope int64 `json:"scope"`
}

Application allows you to interact with authentication server.

func NewApplication

func NewApplication(username string, password string, scope int64) (app Application)

NewApplication creates a new Application instance.

func (*Application) Values

func (app *Application) Values() (values url.Values)

Values returns values from this Application.

type Attachment

type Attachment struct {
	Type      string    `json:"type"`
	AccessKey string    `json:"access_key"`
	Photo     *Photo    `json:"photo"`
	Audio     *Audio    `json:"audio"`
	Video     *Video    `json:"video"`
	Document  *Document `json:"doc"`
	Wall      *Wall     `json:"wall"`
}

type Audio

type Audio struct {
	ID       int64  `json:"id"`
	OwnerID  int64  `json:"owner_id"`
	Artist   string `json:"artist"`
	Title    string `json:"title"`
	Duration int64  `json:"duration"`
	Url      string `json:"url"`
	LyricsID int64  `json:"lyrics_id"`
	AlbumID  int64  `json:"album_id"`
	GenreID  int64  `json:"genre_id"`
	Date     int64  `json:"date"`
	NoSearch int    `json:"no_search"`
}

type AudioMsg

type AudioMsg struct {
	Duration int64   `json:"duration"`
	Waveform []int64 `json:"waveform"`
	LinkOgg  string  `json:"link_ogg"`
	LinkMp3  string  `json:"link_mp3"`
}

type Career

type Career struct {
	GroupId   int64  `json:"group_id"`
	Company   string `json:"company"`
	CountryId int64  `json:"country_id"`
	CityId    int64  `json:"city_id"`
	CityName  string `json:"city_name"`
	From      int64  `json:"from"`
	Until     int64  `json:"until"`
	Position  string `json:"position"`
}

type Chat

type Chat struct {
	ID      int64   `json:"id"`
	Type    string  `json:"type"`
	Title   string  `json:"title"`
	AdminID int64   `json:"admin_id"`
	Users   []int64 `json:"users"`
}

Chat

type City

type City struct {
	Id    int    `json:"id"`
	Title string `json:"title"`
}

type Client

type Client struct {
	LongPoll *LongPoll
	VKUser   VKUser
	VKGroup  VKGroup
	// contains filtered or unexported fields
}

Client allows you to transparently send requests to API server.

func NewClientFromAPIClient

func NewClientFromAPIClient(apiClient *APIClient) (client *Client, err error)

NewClientFromAPIClient creates a new *Client instance.

Example
apiClient := NewApiClient()
apiClient.SetHTTPClient(http.DefaultClient)
apiClient.SetAccessToken("<access token>")
client, _ := NewClientFromAPIClient(apiClient)
if err := client.InitMyProfile(); err != nil {
	log.Panic(err.Error())
}

log.Printf("My name is %s", client.VKUser.Me.FirstName)
Output:

func NewClientFromApplication

func NewClientFromApplication(app Application) (client *Client, err error)

NewClientFromApplication creates a new *Client instance and allows you to pass a custom application.

Example
client, err := NewClientFromApplication(Application{
	Username:     "<username>",
	Password:     "<password>",
	GrantType:    "password",
	ClientID:     "<client_id>",
	ClientSecret: "<client_secret>",
})
if err != nil {
	log.Panic(err)
}

if err := client.InitMyProfile(); err != nil {
	log.Panic(err.Error())
}

log.Printf("My name is %s", client.VKUser.Me.FirstName)
Output:

func NewClientFromLogin

func NewClientFromLogin(username string, password string, scope int64) (client *Client, err error)

NewClientFromLogin creates a new *Client instance and allows you to pass a authentication.

func NewClientFromToken

func NewClientFromToken(token string) (client *Client, err error)

NewClientFromToken creates a new *Client instance.

Example
client, _ := NewClientFromToken("<access_token>")
if err := client.InitLongPoll(0, 2); err != nil {
	log.Panic(err)
}
client.Log(true)
updates, _, err := client.GetLPUpdatesChan(100, LPConfig{25, LPModeAttachments})
if err != nil {
	log.Panic(err)
}

for update := range updates {
	if update.Message == nil {
		continue
	}

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

}
Output:

func (*Client) AddAttachmentDoc

func (client *Client) AddAttachmentDoc(fieldName string, peerID int64, title string, file interface{}) string

func (*Client) AddAttachmentPhoto

func (client *Client) AddAttachmentPhoto(file interface{}) string

func (*Client) Do

func (client *Client) Do(request Request) (response *Response, err *Error)

Do makes a request to a specific endpoint with our request and returns response.

Example
client, _ := NewClientFromToken("<access token>")
values := url.Values{}
values.Set("user_id", "1")
values.Set("count", "10")

res, err := client.Do(NewRequest("groups.get", "", values))
if err != nil {
	panic(err.Error())
}

println(res.Response.String())
Output:

func (*Client) GetChat

func (client *Client) GetChat(chatIDs ...int64) ([]Chat, *Error)

func (*Client) GetFriends

func (client *Client) GetFriends(userID int64, order string, count int64, offset int64, nameCase string, fields ...string) (friends []Users, err *Error)

GetFriends will be return array userID or array Users.

func (*Client) GetGroupById

func (client *Client) GetGroupById(dst Destination, fields ...string) ([]Group, *Error)

func (*Client) GetLPAnswer

func (client *Client) GetLPAnswer(config LPConfig) (LPAnswer, error)

GetLPAnswer makes a query with parameters from LPConfig to long poll server and returns a LPAnswer in case of success.

func (*Client) GetLPUpdates

func (client *Client) GetLPUpdates(config LPConfig) ([]LPUpdate, error)

GetLPUpdates makes a query with parameters from LPConfig to long poll server and returns array LPUpdate in case of success.

func (*Client) GetLPUpdatesChan

func (client *Client) GetLPUpdatesChan(bufSize int, config LPConfig) (LPChan, *bool, error)

GetLPUpdatesChan makes a query with parameters from LPConfig to long poll server and returns LPChan in case of success.

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

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

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

go func() {
	time.Sleep(time.Minute)
	*off = false
}()

for update := range updates {
	log.Print("Code: ", update.Code)
	if update.Message != nil {
		log.Print(update.Message)
	}

	if update.FriendNotification != nil {
		log.Print(update.FriendNotification)
	}
}
Output:

func (*Client) GetMainInfo

func (client *Client) GetMainInfo(dst Destination, sep string) ([]string, *Error)

func (*Client) GetMessages

func (client *Client) GetMessages(previewLength int64, offset int64, count int64, timeOffset int64, filters int, lastMessageID int64, inbox bool) ([]Message, *Error)

GetMessages returns inbox or outbox messages.

func (*Client) GetMessagesByID

func (client *Client) GetMessagesByID(previewLength int64, ids ...int64) ([]Message, *Error)

GetMessagesByID returns messages by ID.

func (*Client) GetMessagesUploadServerForDoc

func (client *Client) GetMessagesUploadServerForDoc(fiendName string, peerID int64) (server UploadServer, err *Error)

func (*Client) GetMessagesUploadServerForPhoto

func (client *Client) GetMessagesUploadServerForPhoto() (server UploadServerPhoto, err *Error)

func (*Client) GetToken

func (client *Client) GetToken() string

GetToken will return access_token

func (*Client) GetWall

func (client *Client) GetWall(dst Destination, count int64, offset int64, filter string, extended bool, fields ...string) (int64, []Wall, []Users, []Group, *Error)

func (*Client) InitLongPoll

func (client *Client) InitLongPoll(needPts int, lpVersion int) *Error

InitLongPoll establishes a new connection to long poll server.

func (*Client) InitMyProfile

func (client *Client) InitMyProfile(fieldArgs ...string) *Error

InitMyProfile fills in the selected Client.VKUser data.

func (*Client) Log

func (client *Client) Log(flag bool) error

Log allow write log.

func (*Client) MarkMessageAsRead

func (client *Client) MarkMessageAsRead(messageIDs ...int64) *Error

func (*Client) MyStatus

func (client *Client) MyStatus() (text string, err error)

MyStatus returns the status from the Client page.

func (*Client) PostWall

func (client *Client) PostWall(config PostConfig) (int64, *Error)

PostWall tries to post a message to the wall with a configuration from PostConfig and returns the post id if it succeeds.

Example
client, _ := NewClientFromToken("<access token>")
client.Log(true)

id, err := client.PostWall(PostConfig{
	Message: "test",
})

if err != nil {
	panic(err.Error())
}
println(id)
Output:

func (*Client) SaveMessagesDoc

func (client *Client) SaveMessagesDoc(file string, title string) (Document, *Error)

func (*Client) SaveMessagesPhoto

func (client *Client) SaveMessagesPhoto(response ServerResponse) (Photo, *Error)

func (*Client) SendDoc

func (client *Client) SendDoc(dst Destination, title string, file interface{}) (int64, *Error)
Example
var id int64
client, _ := NewClientFromToken("<access token>")
client.Log(true)
//#1
client.SendDoc(NewDstFromUserID(id), "logo", "logo.png")
//#2
file, _ := os.Open("logo.png")
client.SendDoc(NewDstFromUserID(id), "logo", FileReader{Reader: file, Size: -1, Name: file.Name()})
//#3
data, _ := ioutil.ReadFile("logo.png")
client.SendDoc(NewDstFromUserID(id), "logo", FileBytes{Bytes: data, Name: "logo.png"})
Output:

func (*Client) SendMessage

func (client *Client) SendMessage(config MessageConfig) (int64, *Error)

SendMessage tries to send a message with the configuration from the MessageConfig and returns message ID if it succeeds.

Example
client, err := NewClientFromLogin("<username>", "<password>", ScopeMessages)
if err != nil {
	log.Panic(err)
}

client.Log(true)

if err := client.InitMyProfile(); err != nil {
	log.Panic(err)
}

// Sends a message to himself.
if _, err := client.SendMessage(NewMessage(NewDstFromUserID(client.VKUser.Me.ID), "Hello!")); err != nil {
	log.Println(err)
}
Output:

func (*Client) SendPhoto

func (client *Client) SendPhoto(dst Destination, file interface{}) (int64, *Error)

func (*Client) SetActivity

func (client *Client) SetActivity(dst Destination) *Error

SetActivity changes the status of typing by user in the dialog.

func (*Client) SetLanguage

func (client *Client) SetLanguage(lang string) error

SetLanguage sets the language in which different data will be returned, for example, names of countries and cities.

func (*Client) SetLogger

func (client *Client) SetLogger(logger *log.Logger) error

SetLogger sets logger.

func (*Client) SetMyStatus

func (client *Client) SetMyStatus(text string) (err error)

SetMyStatus set status on your page.

func (*Client) SetStatus

func (client *Client) SetStatus(groupID int64, text string) (err error)

SetStatus set status in your group.

func (*Client) Status

func (client *Client) Status(dst Destination) (text string, err error)

Status returns the status from user or group page.

func (*Client) UploadFile

func (client *Client) UploadFile(url string, fieldName string, file interface{}) (ServerResponse, *Error)

func (*Client) UsersInfo

func (client *Client) UsersInfo(dst Destination, fieldArgs ...string) (users []Users, err *Error)

UsersInfo returns array Users with the selected fields if the request was successful.

type Comments

type Comments struct {
	Count   int `json:"count"`
	CanPost int `json:"can_post"`
}

type Contacts

type Contacts struct {
	MobilePhone string `json:"mobile_phone"`
	HomePhone   string `json:"home_phone"`
}

type Counters

type Counters struct {
	Albums        int `json:"albums"`
	Videos        int `json:"videos"`
	Audios        int `json:"audios"`
	Photos        int `json:"photos"`
	Notes         int `json:"notes"`
	Friends       int `json:"friends"`
	Groups        int `json:"groups"`
	OnlineFriends int `json:"online_friends"`
	MutualFriends int `json:"mutual_friends"`
	UserVideos    int `json:"user_videos"`
	Followers     int `json:"followers"`
	Pages         int `json:"pages"`
}

type Country

type Country struct {
	Id    int    `json:"id"`
	Title string `json:"title"`
}

type CropPhoto

type CropPhoto struct {
	Photo *Photo `json:"photo"`
	Crop  *Rect  `json:"crop"`
	Rect  *Rect  `json:"rect"`
}

type Destination

type Destination struct {
	UserID      int64    `json:"user_id"`
	PeerID      int64    `json:"peer_id"`
	Domain      string   `json:"domain"`
	ChatID      int64    `json:"chat_id"`
	GroupID     int64    `json:"group_id"`
	GroupName   string   `json:"group_id"`
	GroupIDs    []int64  `json:"group_ids"`
	GroupNames  []string `json:"group_ids"`
	UserIDs     []int64  `json:"user_ids"`
	ScreenName  string   `json:"user_id"`
	ScreenNames []string `json:"user_ids"`
}

Destination describes the final destination.

func NewDstFromChatID

func NewDstFromChatID(chatID int64) (dst Destination)

NewDstFromChatID creates a new MessageConfig instance from chatID.

func NewDstFromDomain

func NewDstFromDomain(domain string) (dst Destination)

NewDstFromDomain creates a new MessageConfig instance from domain.

func NewDstFromGroupID

func NewDstFromGroupID(groupIDs ...int64) (dst Destination)

NewDstFromGroupID creates a new MessageConfig instance from groupID.

func NewDstFromGroupName

func NewDstFromGroupName(groupNames ...string) (dst Destination)

NewDstFromGroupName creates a new MessageConfig instance from groupNames.

func NewDstFromPeerID

func NewDstFromPeerID(peerID int64) (dst Destination)

NewDstFromPeerID creates a new MessageConfig instance from peerID.

func NewDstFromScreenName

func NewDstFromScreenName(screenNames ...string) (dst Destination)

NewDstFromScreenName creates a new MessageConfig instance from screenNames.

func NewDstFromUserID

func NewDstFromUserID(userIDs ...int64) (dst Destination)

NewDstFromUserID creates a new MessageConfig instance from userID.

func (Destination) GetPeerID

func (dst Destination) GetPeerID() int64

func (Destination) Values

func (dst Destination) Values() (values url.Values)

type Dialog

type Dialog struct {
	Unread     int64    `json:"unread"`
	Message    *Message `json:"message"`
	InRead     int64    `json:"in_read"`
	OutRead    int64    `json:"out_read"`
	RealOffset int64    `json:"real_offset"`
}

Dialog describes the structure of the message.

type Document

type Document struct {
	ID        int64  `json:"id"`
	OwnerID   int64  `json:"owner_id"`
	Title     string `json:"title"`
	Size      int64  `json:"size"`
	Ext       string `json:"ext"`
	Url       string `json:"url"`
	Date      int64  `json:"date"`
	Type      int    `json:"type"`
	AccessKey string `json:"access_key"`
	Preview   struct {
		Photo *struct {
			Sizes *[]Sizes `json:"sizes"`
		} `json:"photo"`
		Graffiti *Graffiti `json:"graffiti"`
		AudioMsg *AudioMsg `json:"audio_msg"`
	} `json:"preview"`
}

func (*Document) IsArch

func (doc *Document) IsArch() bool

func (*Document) IsAudio

func (doc *Document) IsAudio() bool

func (*Document) IsEBooks

func (doc *Document) IsEBooks() bool

func (*Document) IsGif

func (doc *Document) IsGif() bool

func (*Document) IsImages

func (doc *Document) IsImages() bool

func (*Document) IsTxt

func (doc *Document) IsTxt() bool

func (*Document) IsUnknown

func (doc *Document) IsUnknown() bool

func (*Document) IsVideo

func (doc *Document) IsVideo() bool

type Encoder

type Encoder struct {
	// contains filtered or unexported fields
}

Encoder is the structure for processing the responses.

func Encode

func Encode(input io.Reader) Encoder

Encode makes Encoder from input data.

func (Encoder) To

func (e Encoder) To(v interface{}) error

To unmarshal the Encoder data.

type Error

type Error struct {
	Code       ServerError     `json:"error_code,omitempty"`
	Message    string          `json:"error_msg,omitempty"`
	Params     *[]RequestParam `json:"request_params,omitempty"`
	CaptchaSid string          `json:"captcha_sid,omitempty"`
	CaptchaImg string          `json:"captcha_img,omitempty"`
	Request    Request         `json:"-"`
}

Error contains standard errors.

func NewError

func NewError(code ServerError, description string) (err *Error)

NewError makes *Error from our ServerError and description.

func (Error) Error

func (e Error) Error() string

func (Error) ToError

func (e Error) ToError() error

type Errors

type Errors []ExecuteError

func (Errors) Error

func (e Errors) Error() string

type ExecuteError

type ExecuteError struct {
	Method  string      `json:"method"`
	Code    ServerError `json:"error_code"`
	Message string      `json:"error_msg"`
}

func (ExecuteError) Error

func (e ExecuteError) Error() string

type FileBytes

type FileBytes struct {
	Name  string
	Bytes []byte
}

FileBytes contains information about a set of bytes to upload as a File.

type FileReader

type FileReader struct {
	Name   string
	Reader io.Reader
	Size   int64
}

FileReader contains information about a reader to upload as a File. If Size is -1, it will read the entire Reader into memory to calculate a Size.

type Geo

type Geo struct {
	Type        string `json:"type"`
	Coordinates string `json:"coordinates"`
	Place       struct {
		ID         int64   `json:"id"`
		Title      string  `json:"title"`
		Latitude   float64 `json:"latitude"`
		Longitude  float64 `json:"longitude"`
		Created    int64   `json:"created"`
		Icon       string  `json:"icon"`
		Country    string  `json:"country"`
		City       string  `json:"city"`
		Type       int     `json:"type"`
		GroupID    int64   `json:"group_id"`
		GroupPhoto int64   `json:"group_photo"`
		Checkins   int64   `json:"checkins"`
		Updated    int64   `json:"updated"`
		Address    int64   `json:"address"`
	} `json:"place"`
}

type Graffiti

type Graffiti struct {
	Src    string `json:"src"`
	Width  int64  `json:"width"`
	Height int64  `json:"height"`
}

type Group

type Group struct {
	ID          int64  `json:"id"`
	Name        string `json:"name"`
	ScreenName  string `json:"screen_name"`
	IsClosed    int    `json:"is_closed"`
	Deactivated string `json:"deactivated"`
	IsAdmin     int    `json:"is_admin"`
	AdminLevel  int    `json:"admin_level"`
	IsMember    int    `json:"is_member"`
	InvitedBy   int    `json:"invited_by"`
	Type        string `json:"type"`
	Photo50     string `json:"photo_50"`
	Photo100    string `json:"photo_100"`
	Photo200    string `json:"photo_200"`
}

type HTTPClient

type HTTPClient interface {
	Do(*http.Request) (*http.Response, error)
}

type LPAnswer

type LPAnswer struct {
	Failed    int64           `json:"failed"`
	Timestamp Timestamp       `json:"ts"`
	Updates   [][]interface{} `json:"updates"`
}

LPAnswer is response from long poll server.

type LPChan

type LPChan <-chan LPUpdate

LPChan allows to receive new LPUpdate.

type LPConfig

type LPConfig struct {
	Wait int
	Mode int
}

LPConfig stores data to connect to long poll server.

type LPFriendNotification

type LPFriendNotification struct {
	ID int64

	// If friend is online,
	// then Arg is equal to platform.
	//
	// If the friend offline, then
	// 0 - friend logout,
	// 1 - offline by timeout.
	Arg       int64
	Timestamp Timestamp
	Activity  int64
}

LPFriendNotification is a notification that a friend has become online or offline.

func (*LPFriendNotification) Platform

func (friend *LPFriendNotification) Platform() (platform string)

Platform returns the name of the platform.

func (*LPFriendNotification) Status

func (friend *LPFriendNotification) Status() (status string)

Status returns event as a string.

func (*LPFriendNotification) String

func (friend *LPFriendNotification) String() string

type LPMessage

type LPMessage struct {
	Type        int64
	ID          int64
	Flags       int64
	FromID      int64
	Timestamp   Timestamp
	Text        string
	Attachments map[string]string
	RandomID    int64
}

LPMessage is new messages that come from long poll server.

func (*LPMessage) ContainsMedia

func (message *LPMessage) ContainsMedia() bool

ContainsMedia will return true if the message contains multimedia content.

func (*LPMessage) Deleted

func (message *LPMessage) Deleted() bool

Deleted will return true if the message was deleted (in the Recycle Bin).

func (*LPMessage) Fixed

func (message *LPMessage) Fixed() bool

Fixed will return true if the message has been scanned by the user for spam.

func (*LPMessage) FromChat

func (message *LPMessage) FromChat() bool

FromChat will return true if this message was sent via chat.

func (*LPMessage) FromFriends

func (message *LPMessage) FromFriends() bool

FromFriends will return true if this message was sent from friends. Not applicable for messages from group conversations.

func (*LPMessage) Important

func (message *LPMessage) Important() bool

Important will return true if this is a marked message.

func (*LPMessage) IsHidden

func (message *LPMessage) IsHidden() bool

IsHidden will return true if it is a welcome message from the community.

func (*LPMessage) IsSpam

func (message *LPMessage) IsSpam() bool

IsSpam will return true if it is spam.

func (*LPMessage) LastMessage

func (message *LPMessage) LastMessage() int64

func (*LPMessage) Outbox

func (message *LPMessage) Outbox() bool

Outbox will return true if this is an outgoing message.

func (*LPMessage) Replied

func (message *LPMessage) Replied() bool

Replied will be returned true if an answer was created to the message.

func (*LPMessage) String

func (message *LPMessage) String() string

func (*LPMessage) Unread

func (message *LPMessage) Unread() bool

Unread will return true if the message is not read.

type LPUpdate

type LPUpdate struct {
	Code               int64
	Update             []interface{}
	Message            *LPMessage
	FriendNotification *LPFriendNotification
}

LPUpdate stores response from a long poll server.

func (*LPUpdate) Event

func (update *LPUpdate) Event() (event string)

Event returns event as a string.

func (*LPUpdate) IsDialogAddFlags

func (update *LPUpdate) IsDialogAddFlags() bool

IsDialogAddFlags will return true if the dialog flags have been added.

func (*LPUpdate) IsDialogDelFlags

func (update *LPUpdate) IsDialogDelFlags() bool

IsDialogDelFlags will return true if the dialog flags have been deleted.

func (*LPUpdate) IsDialogSetFlags

func (update *LPUpdate) IsDialogSetFlags() bool

IsDialogSetFlags will return true if the dialog flags have been replaced.

func (*LPUpdate) IsFriendOffline

func (update *LPUpdate) IsFriendOffline() bool

IsFriendOffline will return true if a friend became offline.

func (*LPUpdate) IsFriendOnline

func (update *LPUpdate) IsFriendOnline() bool

IsFriendOnline will return true if a friend became online.

func (*LPUpdate) IsMessageAddFlags

func (update *LPUpdate) IsMessageAddFlags() bool

IsMessageAddFlags will return true if the message flags have been added.

func (*LPUpdate) IsMessageDelFlags

func (update *LPUpdate) IsMessageDelFlags() bool

IsMessageDelFlags will return true if the message flags have been deleted.

func (*LPUpdate) IsMessageSetFlags

func (update *LPUpdate) IsMessageSetFlags() bool

IsMessageSetFlags will return true if the message flags have been replaced.

func (*LPUpdate) IsNewMessage

func (update *LPUpdate) IsNewMessage() bool

IsNewMessage will return true if it is a new message.

func (*LPUpdate) UnmarshalUpdate

func (update *LPUpdate) UnmarshalUpdate(mode int) error

UnmarshalUpdate unmarshal a LPUpdate.

type LastSeen

type LastSeen struct {
	Time     int64 `json:"time"`
	Platform int   `json:"platform"`
}

type Likes

type Likes struct {
	Count      int `json:"count"`
	UserLikes  int `json:"user_likes"`
	CanLike    int `json:"can_like"`
	CanPublish int `json:"can_publish"`
}

type LongPoll

type LongPoll struct {
	Host      string    `json:"server"`
	Path      string    `json:"path"`
	Key       string    `json:"key"`
	Timestamp Timestamp `json:"ts"`
	LPVersion int       `json:"-"`
	NeedPts   int       `json:"-"`
}

LongPoll allow you to interact with long poll server.

type Message

type Message struct {
	ID          int64         `json:"id"`
	UserID      int64         `json:"user_id"`
	FromID      int64         `json:"from_id"`
	Date        Timestamp     `json:"date"`
	ReadState   int           `json:"read_state"`
	Out         int           `json:"out"`
	Title       string        `json:"title"`
	Body        string        `json:"body"`
	FwdMessages *[]Message    `json:"fwd_messages"`
	Emoji       int           `json:"emoji"`
	Important   int           `json:"important"`
	Deleted     int           `json:"deleted"`
	RandomID    int64         `json:"random_id"`
	ChatID      int64         `json:"chat_id"`
	ChatActive  []int64       `json:"chat_active"`
	UsersCount  int           `json:"users_count"`
	AdminID     int64         `json:"admin_id"`
	Action      string        `json:"action"`
	ActionMid   int64         `json:"action_mid"`
	ActionEmail string        `json:"action_email"`
	ActionText  string        `json:"action_text"`
	Photo50     string        `json:"photo_50"`
	Photo100    string        `json:"photo_100"`
	Photo200    string        `json:"photo_200"`
	Attachments *[]Attachment `json:"attachments"`
	Geo         *Geo          `json:"geo"`
}

Message describes the structure of the message.

func (*Message) IsDeleted

func (message *Message) IsDeleted() bool

IsDeleted will return true if the message was deleted (in the Recycle Bin).

func (*Message) IsOutbox

func (message *Message) IsOutbox() bool

IsOutbox will return true if this is an outgoing message.

func (*Message) String

func (message *Message) String() string

type MessageConfig

type MessageConfig struct {
	Destination     Destination `json:"destination"`
	RandomID        int64       `json:"random_id"`
	Message         string      `json:"message"`
	ForwardMessages []int64     `json:"forward_messages"`
	StickerID       int64       `json:"sticker_id"`
	AccessToken     string      `json:"access_token"`
	Attachment      string      `json:"attachment"`
	// contains filtered or unexported fields
}

MessageConfig contains the data necessary to send a message.

func NewMessage

func NewMessage(dst Destination, message string) (config MessageConfig)

NewMessage creates a new message for the user from the text.

func (*MessageConfig) SetGeo

func (m *MessageConfig) SetGeo(lat float64, long float64)

SetGeo sets the location.

type Military

type Military struct {
	Unit      string `json:"unit"`
	UnitId    int    `json:"unit_id"`
	CountryId int    `json:"country_id"`
	From      int    `json:"from"`
	Until     int    `json:"until"`
}

type Occupation

type Occupation struct {
	Type string `json:"type"`
	Id   int    `json:"id"`
	Name string `json:"name"`
}

type Personal

type Personal struct {
	Political  int      `json:"political"`
	Langs      []string `json:"langs"`
	Religion   string   `json:"religion"`
	InspiredBy string   `json:"inspired_by"`
	PeopleMain int      `json:"people_main"`
	LifeMain   int      `json:"life_main"`
	Smoking    int      `json:"smoking"`
	Alcohol    int      `json:"alcohol"`
}

type Photo

type Photo struct {
	ID        int64    `json:"id"`
	AlbumID   int64    `json:"album_id"`
	OwnerID   int64    `json:"owner_id"`
	UserID    int64    `json:"user_id"`
	Text      string   `json:"text"`
	Date      int64    `json:"date"`
	Sizes     *[]Sizes `json:"sizes"`
	Photo75   string   `json:"photo_75"`
	Photo130  string   `json:"photo_130"`
	Photo604  string   `json:"photo_604"`
	Photo807  string   `json:"photo_807"`
	Photo1280 string   `json:"photo_1280"`
	Photo2560 string   `json:"photo_2560"`
	Width     int      `json:"width"`
	Height    int      `json:"height"`
}

func (*Photo) GetMaxSizePhoto

func (p *Photo) GetMaxSizePhoto() string

type PostConfig

type PostConfig struct {
	OwnerID       int64     `json:"owner_id"`
	FriendsOnly   int       `json:"friends_only"`
	FromGroup     int       `json:"from_group"`
	Attachments   string    `json:"attachments"`
	Message       string    `json:"message"`
	Services      string    `json:"services"`
	PublishDate   Timestamp `json:"publish_date"`
	Signed        int       `json:"signed"`
	Geo           bool      `json:"-"`
	Lat           float64   `json:"lat"`
	Long          float64   `json:"long"`
	PlaceID       int64     `json:"place_id"`
	PostID        int64     `json:"post_id"`
	Guid          string    `json:"guid"`
	MarkAsAds     int       `json:"mark_as_ads"`
	CloseComments int       `json:"close_comments"`
}

func (*PostConfig) SetGeo

func (p *PostConfig) SetGeo(lat float64, long float64)

SetGeo sets the location.

type PostSource

type PostSource struct {
	Type     string `json:"type"`
	Platform string `json:"platform"`
	Data     string `json:"data"`
	URL      string `json:"url"`
}

type Raw

type Raw []byte

Raw similar to the jsonRAW.

func (Raw) Bytes

func (r Raw) Bytes() []byte

func (Raw) MarshalJSON

func (r Raw) MarshalJSON() ([]byte, error)

func (Raw) String

func (r Raw) String() string

func (*Raw) UnmarshalJSON

func (r *Raw) UnmarshalJSON(data []byte) error

type Rect

type Rect struct {
	X  float64
	X2 float64
	Y  float64
	Y2 float64
}

type Relatives

type Relatives struct {
	Id   int    `json:"id"`
	Name string `json:"name"`
	Type string `json:"type"`
}

type Reposts

type Reposts struct {
	Count        int `json:"count"`
	UserReposted int `json:"user_reposted"`
}

type Request

type Request struct {
	Method string     `json:"method"`
	Token  string     `json:"token"`
	Values url.Values `json:"values"`
}

Request contains data for the request to the API server.

func NewRequest

func NewRequest(method string, token string, values url.Values) (req Request)

NewRequest creates a new Request instance.

func (Request) HTTP

func (r Request) HTTP() (req *http.Request)

HTTP translates the Request in *http.Request.

func (Request) JS

func (r Request) JS() string

JS translates the Request in string.

type RequestParam

type RequestParam struct {
	Key   string `json:"key"`
	Value string `json:"value"`
}

type Response

type Response struct {
	Errors   *Errors `json:"execute_errors,omitempty"`
	Error    *Error  `json:"error,omitempty"`
	Response Raw     `json:"response,omitempty"`
}

Response is response from API server.

func (Response) ServerError

func (r Response) ServerError() error

ServerError checks the Response to the error.

func (Response) To

func (r Response) To(v interface{}) error

To unmarshal the Response data.

type Schools

type Schools struct {
	Id            string `json:"id"`
	Country       int    `json:"country"`
	City          int    `json:"city"`
	Name          string `json:"name"`
	YearFrom      int    `json:"year_from"`
	YearTo        int    `json:"year_to"`
	YearGraduated int    `json:"year_graduated"`
	Class         string `json:"class"`
	Speciality    string `json:"speciality"`
	Type          int    `json:"type"`
	TypeStr       string `json:"type_str"`
}

type ServerError

type ServerError int
const (
	// Full description at https://vk.com/dev/errors
	ErrZero                      ServerError = 0
	ErrUnknown                   ServerError = 1
	ErrApplicationDisabled       ServerError = 2
	ErrUnknownMethod             ServerError = 3
	ErrInvalidSignature          ServerError = 4
	ErrAuthFailed                ServerError = 5
	ErrTooManyRequests           ServerError = 6
	ErrInsufficientPermissions   ServerError = 7
	ErrInvalidRequest            ServerError = 8
	ErrTooManyOneTypeRequests    ServerError = 9
	ErrInternalServerError       ServerError = 10
	ErrAppInTestMode             ServerError = 11
	ErrCaptchaNeeded             ServerError = 14
	ErrNotAllowed                ServerError = 15
	ErrHttpsOnly                 ServerError = 16
	ErrNeedValidation            ServerError = 17
	ErrUserDeletedOrBlocked      ServerError = 18
	ErrStandaloneOnly            ServerError = 20
	ErrStandaloneOpenAPIOnly     ServerError = 21
	ErrMethodDisabled            ServerError = 23
	ErrNeedConfirmation          ServerError = 24
	ErrCommunityKeyInvalid       ServerError = 27
	ErrApplicationKeyInvalid     ServerError = 28
	ErrOneOfParametersInvalid    ServerError = 100
	ErrInvalidAPIID              ServerError = 101
	ErrInvalidAUserID            ServerError = 113
	ErrInvalidTimestamp          ServerError = 150
	ErrAlbumAccessProhibited     ServerError = 200
	ErrAudioAccessProhibited     ServerError = 201
	ErrGroupAccessProhibited     ServerError = 203
	ErrAlbumOverflow             ServerError = 300
	ErrEnableVoiceApplication    ServerError = 500
	ErrInsufficientPermissionsAd ServerError = 600
	ErrInternalServerErrorAd     ServerError = 603

	ErrInBlackList           ServerError = 900
	ErrNotAllowedToSendFirst ServerError = 901
	ErrPrivacy               ServerError = 902

	ErrBadResponseCode ServerError = -1
	ErrBadCode         ServerError = -666
)

func (ServerError) Error

func (s ServerError) Error() string

func (ServerError) String

func (s ServerError) String() string

type ServerResponse

type ServerResponse struct {
	Response
	Server int64  `json:"server"`
	Photo  string `json:"photo"`
	File   string `json:"file"`
	Hash   string `json:"hash"`
}

type Sizes

type Sizes struct {
	Src    string `json:"src"`
	Width  int    `json:"width"`
	Height int    `json:"height"`
	Type   string `json:"type"`
}

type Timestamp

type Timestamp int64

Timestamp is the wrapper of int64.

func (Timestamp) String

func (ts Timestamp) String() string

type Universities

type Universities struct {
	Id              int    `json:"id"`
	Country         int    `json:"country"`
	City            int    `json:"city"`
	Name            string `json:"name"`
	Faculty         int    `json:"faculty"`
	FacultyName     string `json:"faculty_name"`
	Chair           int    `json:"chair"`
	ChairName       string `json:"chair_name"`
	Graduation      int    `json:"graduation"`
	EducationForm   string `json:"education_form"`
	EducationStatus string `json:"education_status"`
}

type UploadServer

type UploadServer struct {
	UploadURL string `json:"upload_url"`
}

type UploadServerPhoto

type UploadServerPhoto struct {
	UploadServer
	UserID  int64 `json:"user_id"`
	AlbumID int64 `json:"album_id"`
}

type Users

type Users struct {
	// Full description at https://vk.com/dev/objects/user
	ID          int64  `json:"id"`
	FirstName   string `json:"first_name"`
	LastName    string `json:"last_name"`
	Deactivated string `json:"deactivated"`
	Hidden      int    `json:"hidden"`

	// Optional fields
	About                  string          `json:"about,omitempty"`
	Activities             string          `json:"activities,omitempty"`
	Bdate                  string          `json:"bdate,omitempty"`
	Blacklisted            int             `json:"blacklisted,omitempty"`
	BlacklistedByMe        int             `json:"blacklisted_by_me,omitempty"`
	Books                  string          `json:"books,omitempty"`
	CanPost                int             `json:"can_post,omitempty"`
	CanSeeAllPosts         int             `json:"can_see_all_posts,omitempty"`
	CanSeeAudio            int             `json:"can_see_audio,omitempty"`
	CanSendFriendRequest   int             `json:"can_send_friend_request,omitempty"`
	CanWritePrivateMessage int             `json:"can_write_private_message,omitempty"`
	Career                 *[]Career       `json:"career,omitempty"`
	City                   *City           `json:"city,omitempty"`
	CommonCount            int64           `json:"common_count,omitempty"`
	Skype                  string          `json:"skype,omitempty"`
	Facebook               string          `json:"facebook,omitempty"`
	Twitter                string          `json:"twitter,omitempty"`
	Livejournal            string          `json:"livejournal,omitempty"`
	Instagram              string          `json:"instagram,omitempty"`
	Contacts               *Contacts       `json:"contacts,omitempty"`
	Counters               *Counters       `json:"counters,omitempty"`
	Country                *Country        `json:"country,omitempty"`
	CropPhoto              *CropPhoto      `json:"crop_photo,omitempty"`
	Domain                 string          `json:"domain,omitempty"`
	University             int64           `json:"university,omitempty"`
	UniversityName         string          `json:"university_name,omitempty"`
	Faculty                int64           `json:"faculty,omitempty"`
	FacultyName            string          `json:"faculty_name,omitempty"`
	Graduation             int64           `json:"graduation,omitempty"`
	FirstNameNom           string          `json:"first_name_nom,omitempty"`
	FirstNameGen           string          `json:"first_name_gen,omitempty"`
	FirstNameDat           string          `json:"first_name_dat,omitempty"`
	FirstNameAcc           string          `json:"first_name_acc,omitempty"`
	FirstNameIns           string          `json:"first_name_ins,omitempty"`
	FirstNameAbl           string          `json:"first_name_abl,omitempty"`
	FollowersCount         int64           `json:"followers_count,omitempty"`
	FriendStatus           int             `json:"friend_status,omitempty"`
	Games                  string          `json:"games,omitempty"`
	HasMobile              int             `json:"has_mobile,omitempty"`
	HasPhoto               int             `json:"hasPhoto,omitempty"`
	HomeTown               string          `json:"home_town,omitempty"`
	Interests              string          `json:"interests,omitempty"`
	IsFavorite             int             `json:"is_favorite,omitempty"`
	IsFriend               int             `json:"is_friend,omitempty"`
	IsHiddenFromFeed       int             `json:"is_hidden_from_feed,omitempty"`
	LastNameNom            string          `json:"last_name_nom,omitempty"`
	LastNameGen            string          `json:"last_name_gen,omitempty"`
	LastNameDat            string          `json:"last_name_dat,omitempty"`
	LastNameAcc            string          `json:"last_name_acc,omitempty"`
	LastNameIns            string          `json:"last_name_ins,omitempty"`
	LastNameAbl            string          `json:"last_name_abl,omitempty"`
	LastSeen               *LastSeen       `json:"last_seen,omitempty"`
	MaidenName             string          `json:"maiden_name,omitempty"`
	Military               *[]Military     `json:"military,omitempty"`
	Movies                 string          `json:"movies,omitempty"`
	Music                  string          `json:"music,omitempty"`
	Nickname               string          `json:"nickname,omitempty"`
	Occupation             *Occupation     `json:"occupation,omitempty"`
	Online                 int             `json:"online,omitempty"`
	Personal               *Personal       `json:"personal,omitempty"`
	Photo50                string          `json:"photo_50,omitempty"`
	Photo100               string          `json:"photo_100,omitempty"`
	Photo200Orig           string          `json:"photo_200_orig,omitempty"`
	Photo200               string          `json:"photo_200,omitempty"`
	Photo400Orig           string          `json:"photo_400_orig,omitempty"`
	PhotoId                string          `json:"photo_id,omitempty"`
	PhotoMax               string          `json:"photo_max,omitempty"`
	PhotoMaxOrig           string          `json:"photo_max_orig,omitempty"`
	Quotes                 string          `json:"quotes,omitempty"`
	Relatives              *[]Relatives    `json:"relatives,omitempty"`
	Relation               int             `json:"relation,omitempty"`
	Schools                *[]Schools      `json:"schools,omitempty"`
	ScreenName             string          `json:"screen_name,omitempty"`
	Sex                    int             `json:"sex,omitempty"`
	Site                   string          `json:"site,omitempty"`
	Status                 string          `json:"status,omitempty"`
	StatusAudio            string          `json:"status_audio,omitempty"`
	Timezone               int             `json:"timezone,omitempty"`
	Tv                     string          `json:"tv,omitempty"`
	Universities           *[]Universities `json:"universities,omitempty"`
	Verified               int             `json:"verified,omitempty"`
	WallComments           int             `json:"wall_comments,omitempty"`
}

Users describes the structure of the users.

func (*Users) MainInfo

func (user *Users) MainInfo(sep string) string

type VKGroup

type VKGroup struct {
	Members []int64
}

type VKUser

type VKUser struct {
	Me      Users
	Friends []Users
}

VKUser describes the structure of the vk user.

type Video

type Video struct {
	ID          int64  `json:"id"`
	OwnerID     int64  `json:"owner_id"`
	Title       string `json:"title"`
	Description string `json:"description"`
	Duration    int64  `json:"duration"`
	Photo130    string `json:"photo_130"`
	Photo320    string `json:"photo_320"`
	Photo640    string `json:"photo_640"`
	Photo800    string `json:"photo_800"`
	Date        int64  `json:"date"`
	AddingDate  int64  `json:"adding_date"`
	Views       int64  `json:"views"`
	Comments    int64  `json:"comments"`
	Player      string `json:"player"`
	AccessKey   string `json:"access_key"`
	Processing  int    `json:"processing"`
	Live        int    `json:"live"`
	Upcoming    int    `json:"upcoming"`
}

func (*Video) GetMaxPreview

func (v *Video) GetMaxPreview() string

type Views

type Views struct {
	Count int `json:"count"`
}

type Wall

type Wall struct {
	ID           int64         `json:"id"`
	OwnerID      int64         `json:"owner_id"`
	ToID         int64         `json:"to_id"`
	FromID       int64         `json:"from_id"`
	Date         int64         `json:"date"`
	Text         string        `json:"text"`
	ReplyOwnerID int64         `json:"reply_owner_id"`
	ReplyPostID  int64         `json:"reply_post_id"`
	FriendsOnly  int           `json:"friends_only"`
	Comments     *Comments     `json:"comments"`
	Likes        *Likes        `json:"likes"`
	Reposts      *Reposts      `json:"reposts"`
	Views        *Views        `json:"views"`
	PostType     string        `json:"post_type"`
	PostSource   *PostSource   `json:"post_source"`
	Attachments  *[]Attachment `json:"attachments"`
	Geo          *Geo          `json:"geo"`
	SingerID     int64         `json:"singer_id"`
	CopyHistory  *[]Wall       `json:"copy_history"`
	CanPin       int           `json:"can_pin"`
	CanDelete    int           `json:"can_delete"`
	CanEdit      int           `json:"can_edit"`
	IsPinned     int           `json:"is_pinned"`
	MarkedAsAds  int           `json:"marked_as_ads"`
}

func (*Wall) URL

func (w *Wall) URL() string

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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