Documentation
¶
Index ¶
- Constants
- Variables
- func ApiURL() (url url.URL)
- func ConcatInt64ToString(numbers ...int64) string
- func ConcatValues(unite bool, values ...url.Values) (result url.Values)
- func OAuthURL() (url url.URL)
- func Process(input io.Reader) (response *Response, err *Error)
- type APIClient
- func (api *APIClient) Authenticate(application Application) (err error)
- func (api *APIClient) Do(request Request) (response *Response, error *Error)
- func (api *APIClient) SetAccessToken(token string)
- func (api *APIClient) SetHTTPClient(httpClient HTTPClient)
- func (api *APIClient) SetLogger(logger *log.Logger)
- func (api *APIClient) Values() (values url.Values)
- type AccessToken
- type Application
- type Attachment
- type Audio
- type AudioMsg
- type Career
- type Chat
- type City
- type Client
- func NewClientFromAPIClient(apiClient *APIClient) (client *Client, err error)
- func NewClientFromApplication(app Application) (client *Client, err error)
- func NewClientFromLogin(username string, password string, scope int64) (client *Client, err error)
- func NewClientFromToken(token string) (client *Client, err error)
- func (client *Client) AddAttachmentDoc(fieldName string, peerID int64, title string, file interface{}) string
- func (client *Client) AddAttachmentPhoto(file interface{}) string
- func (client *Client) Do(request Request) (response *Response, err *Error)
- func (client *Client) GetChat(chatIDs ...int64) ([]Chat, *Error)
- func (client *Client) GetFriends(userID int64, order string, count int64, offset int64, nameCase string, ...) (friends []Users, err *Error)
- func (client *Client) GetGroupById(dst Destination, fields ...string) ([]Group, *Error)
- func (client *Client) GetLPAnswer(config LPConfig) (LPAnswer, error)
- func (client *Client) GetLPUpdates(config LPConfig) ([]LPUpdate, error)
- func (client *Client) GetLPUpdatesChan(bufSize int, config LPConfig) (LPChan, *bool, error)
- func (client *Client) GetMainInfo(dst Destination, sep string) ([]string, *Error)
- func (client *Client) GetMessages(previewLength int64, offset int64, count int64, timeOffset int64, filters int, ...) ([]Message, *Error)
- func (client *Client) GetMessagesByID(previewLength int64, ids ...int64) ([]Message, *Error)
- func (client *Client) GetMessagesUploadServerForDoc(fiendName string, peerID int64) (server UploadServer, err *Error)
- func (client *Client) GetMessagesUploadServerForPhoto() (server UploadServerPhoto, err *Error)
- func (client *Client) GetToken() string
- func (client *Client) GetWall(dst Destination, count int64, offset int64, filter string, extended bool, ...) (int64, []Wall, []Users, []Group, *Error)
- func (client *Client) InitLongPoll(needPts int, lpVersion int) *Error
- func (client *Client) InitMyProfile(fieldArgs ...string) *Error
- func (client *Client) Log(flag bool) error
- func (client *Client) MarkMessageAsRead(messageIDs ...int64) *Error
- func (client *Client) MyStatus() (text string, err error)
- func (client *Client) SaveMessagesDoc(file string, title string) (Document, *Error)
- func (client *Client) SaveMessagesPhoto(response ServerResponse) (Photo, *Error)
- func (client *Client) SendDoc(dst Destination, title string, file interface{}) (int64, *Error)
- func (client *Client) SendMessage(config MessageConfig) (int64, *Error)
- func (client *Client) SendPhoto(dst Destination, file interface{}) (int64, *Error)
- func (client *Client) SetActivity(dst Destination) *Error
- func (client *Client) SetLanguage(lang string) error
- func (client *Client) SetLogger(logger *log.Logger) error
- func (client *Client) SetMyStatus(text string) (err error)
- func (client *Client) SetStatus(groupID int64, text string) (err error)
- func (client *Client) Status(dst Destination) (text string, err error)
- func (client *Client) UploadFile(url string, fieldName string, file interface{}) (ServerResponse, *Error)
- func (client *Client) UsersInfo(dst Destination, fieldArgs ...string) (users []Users, err *Error)
- type Comments
- type Contacts
- type Counters
- type Country
- type CropPhoto
- type Destination
- func NewDstFromChatID(chatID int64) (dst Destination)
- func NewDstFromDomain(domain string) (dst Destination)
- func NewDstFromGroupID(groupIDs ...int64) (dst Destination)
- func NewDstFromGroupName(groupNames ...string) (dst Destination)
- func NewDstFromPeerID(peerID int64) (dst Destination)
- func NewDstFromScreenName(screenNames ...string) (dst Destination)
- func NewDstFromUserID(userIDs ...int64) (dst Destination)
- type Dialog
- type Document
- type Encoder
- type Error
- type Errors
- type ExecuteError
- type FileBytes
- type FileReader
- type Geo
- type Graffiti
- type Group
- type HTTPClient
- type LPAnswer
- type LPChan
- type LPConfig
- type LPFriendNotification
- type LPMessage
- func (message *LPMessage) ContainsMedia() bool
- func (message *LPMessage) Deleted() bool
- func (message *LPMessage) Fixed() bool
- func (message *LPMessage) FromChat() bool
- func (message *LPMessage) FromFriends() bool
- func (message *LPMessage) Important() bool
- func (message *LPMessage) IsHidden() bool
- func (message *LPMessage) IsSpam() bool
- func (message *LPMessage) LastMessage() int64
- func (message *LPMessage) Outbox() bool
- func (message *LPMessage) Replied() bool
- func (message *LPMessage) String() string
- func (message *LPMessage) Unread() bool
- type LPUpdate
- func (update *LPUpdate) Event() (event string)
- func (update *LPUpdate) IsDialogAddFlags() bool
- func (update *LPUpdate) IsDialogDelFlags() bool
- func (update *LPUpdate) IsDialogSetFlags() bool
- func (update *LPUpdate) IsFriendOffline() bool
- func (update *LPUpdate) IsFriendOnline() bool
- func (update *LPUpdate) IsMessageAddFlags() bool
- func (update *LPUpdate) IsMessageDelFlags() bool
- func (update *LPUpdate) IsMessageSetFlags() bool
- func (update *LPUpdate) IsNewMessage() bool
- func (update *LPUpdate) UnmarshalUpdate(mode int) error
- type LastSeen
- type Likes
- type LongPoll
- type Message
- type MessageConfig
- type Military
- type Occupation
- type Personal
- type Photo
- type PostSource
- type Raw
- type Rect
- type Relatives
- type Reposts
- type Request
- type RequestParam
- type Response
- type Schools
- type ServerError
- type ServerResponse
- type Sizes
- type Timestamp
- type Universities
- type UploadServer
- type UploadServerPhoto
- type Users
- type VKGroup
- type VKUser
- type Video
- type Views
- type Wall
Examples ¶
Constants ¶
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 )
const ( FriendFieldHints = "hints" FriendFieldRandom = "random" FriendFieldMobile = "mobile" FriendFieldName = "name" )
const ( LPMessageFlagUnread = 1 << iota LPMessageFlagOutBox LPMessageFlagReplied LPMessageFlagImportant LPMessageFlagChat LPMessageFlagFriends LPMessageFlagSpam LPMessageFlagDeleted LPMessageFlagFixed LPMessageFlagMedia LPMessageFlagHidden = 65536 )
const ( LPModeAttachments = 2 LPModeExtendedEvent = 8 LPModePts = 32 LPModeExtra = 64 LPModeRandomID = 128 )
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 )
const ( LPPlatformUndefined = iota LPPlatformMobile LPPlatformIPhone LPPlatformIPad LPPlatformAndroid LPPlatformWPhone LPPlatformWindows LPPlatformWeb )
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 )
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" )
const ( PostTypePost = "post" PostTypeCopy = "copy" PostTypeReply = "reply" PostTypePostpone = "postpone" PostTypeSuggest = "suggest" )
const (
ErrApiClientNotFound = "APIClient not found."
)
Variables ¶
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 ConcatInt64ToString ¶
ConcatInt64ToString concatenating array int64 and returns them as a string.
func ConcatValues ¶
ConcatValues concatenating values
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 (*APIClient) Authenticate ¶
func (api *APIClient) Authenticate(application Application) (err error)
Authenticate run authentication this APIClient from Application.
func (*APIClient) Do ¶
Do sends a request to a specific endpoint with our request and returns response.
func (*APIClient) SetAccessToken ¶
SetAccessToken sets access token to APIClient.
func (*APIClient) SetHTTPClient ¶
func (api *APIClient) SetHTTPClient(httpClient HTTPClient)
SetHTTPClient sets HTTPClient to 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 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 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 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 ¶
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)
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)
func NewClientFromLogin ¶
NewClientFromLogin creates a new *Client instance and allows you to pass a authentication.
func NewClientFromToken ¶
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!"))
}
}
func (*Client) AddAttachmentDoc ¶
func (*Client) AddAttachmentPhoto ¶
func (*Client) Do ¶
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())
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 ¶
GetLPAnswer makes a query with parameters from LPConfig to long poll server and returns a LPAnswer in case of success.
func (*Client) GetLPUpdates ¶
GetLPUpdates makes a query with parameters from LPConfig to long poll server and returns array LPUpdate in case of success.
func (*Client) GetLPUpdatesChan ¶
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)
}
}
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 ¶
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) InitLongPoll ¶
InitLongPoll establishes a new connection to long poll server.
func (*Client) InitMyProfile ¶
InitMyProfile fills in the selected Client.VKUser data.
func (*Client) MarkMessageAsRead ¶
func (*Client) SaveMessagesDoc ¶
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"})
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)
}
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 ¶
SetLanguage sets the language in which different data will be returned, for example, names of countries and cities.
func (*Client) SetMyStatus ¶
SetMyStatus set status on your page.
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)
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 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"`
}
type Encoder ¶
type Encoder struct {
// contains filtered or unexported fields
}
Encoder is the structure for processing the responses.
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.
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 FileReader ¶
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 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 LPAnswer ¶
type LPAnswer struct {
Failed int64 `json:"failed"`
Timestamp Timestamp `json:"ts"`
Updates [][]interface{} `json:"updates"`
}
LPAnswer is response from 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 ¶
ContainsMedia will return true if the message contains multimedia content.
func (*LPMessage) Deleted ¶
Deleted will return true if the message was deleted (in the Recycle Bin).
func (*LPMessage) Fixed ¶
Fixed will return true if the message has been scanned by the user for spam.
func (*LPMessage) FromFriends ¶
FromFriends will return true if this message was sent from friends. Not applicable for messages from group conversations.
func (*LPMessage) IsHidden ¶
IsHidden will return true if it is a welcome message from the community.
func (*LPMessage) LastMessage ¶
type LPUpdate ¶
type LPUpdate struct {
Code int64
Update []interface{}
Message *LPMessage
FriendNotification *LPFriendNotification
}
LPUpdate stores response from a long poll server.
func (*LPUpdate) IsDialogAddFlags ¶
IsDialogAddFlags will return true if the dialog flags have been added.
func (*LPUpdate) IsDialogDelFlags ¶
IsDialogDelFlags will return true if the dialog flags have been deleted.
func (*LPUpdate) IsDialogSetFlags ¶
IsDialogSetFlags will return true if the dialog flags have been replaced.
func (*LPUpdate) IsFriendOffline ¶
IsFriendOffline will return true if a friend became offline.
func (*LPUpdate) IsFriendOnline ¶
IsFriendOnline will return true if a friend became online.
func (*LPUpdate) IsMessageAddFlags ¶
IsMessageAddFlags will return true if the message flags have been added.
func (*LPUpdate) IsMessageDelFlags ¶
IsMessageDelFlags will return true if the message flags have been deleted.
func (*LPUpdate) IsMessageSetFlags ¶
IsMessageSetFlags will return true if the message flags have been replaced.
func (*LPUpdate) IsNewMessage ¶
IsNewMessage will return true if it is a new message.
func (*LPUpdate) UnmarshalUpdate ¶
UnmarshalUpdate unmarshal a LPUpdate.
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 ¶
IsDeleted will return true if the message was deleted (in the Recycle Bin).
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 Occupation ¶
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 ¶
type PostSource ¶
type Raw ¶
type Raw []byte
Raw similar to the jsonRAW.
func (Raw) MarshalJSON ¶
func (*Raw) UnmarshalJSON ¶
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 ¶
NewRequest creates a new Request instance.
type RequestParam ¶
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 ¶
ServerError checks the Response to the error.
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 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.
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 ¶
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"`
}
