Documentation
¶
Overview ¶
Package vk implements VKontakte API (including OAuth)
Index ¶
- Constants
- Variables
- func ClearCaptcha()
- func ElemInSlice(elem string, slice []string) bool
- func NewDelayer(d time.Duration) *delayer
- func NewUnlinker(sess *Session, ts ...int) unlinker
- func PublicAPI(method string, params url.Values, out interface{}) error
- func SetCaptcha(id, key string)
- func SetServer(s *Session, surl string, gid int) error
- func UnlinkAttachments(u unlinker, s string) (err error)
- type API
- type AccessToken
- type ApiList
- type Attachment
- func (a *Attachment) Audio() (*Audio, error)
- func (a *Attachment) Doc() (*Doc, error)
- func (a *Attachment) Photo() (*Photo, error)
- func (a *Attachment) Poll() (*Poll, error)
- func (a *Attachment) Sticker() (*Sticker, error)
- func (a *Attachment) UnmarshalJSON(b []byte) error
- func (a *Attachment) Video() (*Video, error)
- type AttachmentUploader
- type Audio
- type Bool
- type CBConfirmCode
- type CBServerSettings
- type CBSettings
- type Comment
- type Doc
- type EpochTime
- type Error
- type Geo
- type GeoPlace
- type Group
- type GroupJoin
- type GroupLeave
- type GroupLooper
- type IdList
- type Int
- type LikeType
- type Message
- type Messages
- type NotifItem
- func (n *NotifItem) FeedbackAsComment() (*Comment, error)
- func (n *NotifItem) FeedbackAsPost() (*Post, error)
- func (n *NotifItem) FeedbackIsComment() bool
- func (n *NotifItem) FeedbackIsPost() bool
- func (n *NotifItem) ParentAsComment() (*Comment, error)
- func (n *NotifItem) ParentAsPost() (*Post, error)
- func (n *NotifItem) ParentAsTopic() (*Topic, error)
- func (n *NotifItem) ParentIsComment() bool
- func (n *NotifItem) ParentIsPost() bool
- type Notifications
- type Photo
- type PhotoObj
- type PlatformInfo
- type Playlist
- type Poll
- type Post
- type Receive
- type ReceiveContent
- type ReceivedResult
- func (rr *ReceivedResult) Audio() (*Audio, error)
- func (rr *ReceivedResult) Board() (*TopicComment, error)
- func (rr *ReceivedResult) GetBoardDelete() (*TopicDelete, error)
- func (rr *ReceivedResult) GetGroupJoin() (*GroupJoin, error)
- func (rr *ReceivedResult) GetGroupLeave() (*GroupLeave, error)
- func (rr *ReceivedResult) PM() (*Message, error)
- func (rr *ReceivedResult) Photo() (*Photo, error)
- func (rr *ReceivedResult) Video() (*Video, error)
- func (rr *ReceivedResult) WallComment() (*Comment, error)
- func (rr *ReceivedResult) WallPost() (*Post, error)
- type Relative
- type School
- type Scope
- type Session
- func (s *Session) AudioGet(ids ...int) ([]Audio, error)
- func (s *Session) AudioGetAlbums(owner int, offset, count int) ([]Playlist, error)
- func (s *Session) AudioGetById(ids [][2]int) ([]Audio, error)
- func (s *Session) AudioGetFromAlbum(album int, offset, count int) ([]Audio, error)
- func (s *Session) AudioGetFromUser(user int, offset, count int) ([]Audio, error)
- func (s *Session) AudioSearch(qu string, count int, autoCompl, perfOnly bool) ([]Audio, error)
- func (s *Session) CallAPI(method string, params url.Values, out interface{}) error
- func (s *Session) FriendsGet(user int, offset, count int, fields []string, nameCase string) ([]User, error)
- func (s *Session) Likes(t LikeType, id int, likesOptions ...interface{}) (int, error)
- func (s *Session) MsgsGet(out bool, filters int, lastId int) (*Messages, error)
- func (s *Session) MsgsMarkAsRead(ids []int) (Bool, error)
- func (s *Session) NotifGet(startFrm string, filters []string, start, end int64) (*Notifications, error)
- func (s *Session) NotifMarkAsViewed() (Bool, error)
- func (s *Session) Unlikes(t LikeType, id int, likesOptions ...interface{}) (int, error)
- func (s *Session) UploadAudio(path string, gid int) (json.RawMessage, error)
- func (s *Session) UploadDoc(path string) (json.RawMessage, error)
- func (s *Session) UploadDocToWall(path string) (json.RawMessage, error)
- func (s *Session) UploadMultiAlbumPhotos(ps, ns []string, o, a int) ([]string, error)
- func (s *Session) UploadMultiAudios(ps, ns []string, gid int) ([]string, error)
- func (s *Session) UploadMultiDocs(ps, ns []string, gid int) ([]string, error)
- func (s *Session) UploadMultiPMPhotos(ps, ns []string, gid int) ([]string, error)
- func (s *Session) UploadMultiPhotos(ps, ns []string, owner int) ([]string, error)
- func (s *Session) UploadMultiVideos(ps, ns []string, owner int) ([]string, error)
- func (s *Session) UploadMultiWallDocs(ps, ns []string, owner int) ([]string, error)
- func (s *Session) UploadPhotosToAlbum(ss []string, gid, aid int) (json.RawMessage, error)
- func (s *Session) UploadPhotosToPM(ss []string, gid int) (json.RawMessage, error)
- func (s *Session) UploadPhotosToWall(ss []string, gid int) (json.RawMessage, error)
- func (s *Session) UploadVideos(path string, v url.Values) error
- func (s *Session) User(fields []string, nameCase string) (User, error)
- func (s *Session) UsersGet(userIds []int, fields []string, nameCase string) ([]User, error)
- func (s *Session) UsersGetFollowers(user int, fields []string, nameCase string, offset, count int) ([]User, error)
- func (s *Session) UsersIsAppUser(user int) (bool, error)
- func (s *Session) WallDelete(id int, ownerOpts ...interface{}) error
- func (s *Session) WallPin(id int, ownerOpts ...interface{}) error
- func (s *Session) WallPost(m, a string, ownerOpts ...interface{}) (int, error)
- func (s *Session) WallPostEdit(id int, m, a string, ownerOpts ...interface{}) error
- func (s *Session) WallRestore(id int, ownerOpts ...interface{}) error
- func (s *Session) WallUnpin(id int, ownerOpts ...interface{}) error
- type SmallGroup
- type SmallGroups
- type SmallUser
- type SmallUsers
- type Sticker
- type Topic
- type TopicComment
- type TopicDelete
- type University
- type UploadAlbumPhotos
- type UploadAudios
- type UploadDocs
- type UploadServer
- type UploadVideos
- type UploadWallPhotos
- type User
- type Video
- type VideoObj
Constants ¶
const ( // attachment type AT_Photo = "photo" AT_Sticker = "sticker" AT_PostedPhoto = "posted_photo" AT_Video = "video" AT_Audio = "audio" AT_Doc = "doc" AT_Graffiti = "graffiti" AT_Url = "url" AT_Link = "link" AT_Note = "note" AT_App = "app" AT_Poll = "poll" AT_Page = "page" )
const ( ErrZero = iota ErrUnknown ErrAppDis ErrUnknownMethod ErrIncorrectSignature ErrAuthorizeFailed ErrTooManyReq ErrActDenied ErrInvalidReq ErrFloodControl ErrInternalServer ErrTestMode ErrTwelve ErrThirteen ErrCaptcha ErrAccDenied ErrHTTPAuthorizeFailed ErrValidationRequired ErrEighteen ErrNineteen ErrActDeniedNonStandalone ErrActOnlyStandalone ErrTwentyTwo ErrMethodDis ErrConfirmRequired ErrParamMissing = 100 ErrInvalidAppAPIID = 101 ErrInvalidUserID = 113 ErrInvalidTimestamp = 150 )
const ( NotifFollow = "follow" NotifFriendAccepted = "friend_accepted" NotifMention = "mention" NotifMentionComments = "mention_comments" NotifWall = "wall" NotifCommentPost = "comment_post" NotifCommentPhoto = "comment_photo" NotifCommentVideo = "comment_video" NotifReplyComment = "reply_comment" NotifReplyCommentPhoto = "reply_comment_photo" NotifReplyCommentVideo = "reply_comment_video" NotifReplyTopic = "reply_topic" NotifLikePost = "like_post" NotifLikeComment = "like_comment" NotifLikePhoto = "like_photo" NotifLikeVideo = "like_video" NotifLikeCommentPhoto = "like_comment_photo" NotifLikeCommentVideo = "like_comment_video" NotifLikeCommentTopic = "like_comment_topic" NotifCopyPost = "copy_post" NotifCopyPhoto = "copy_photo" NotifCopyVideo = "copy_video" )
const ( MsgUnreadOnly = 1 MsgNotChat = 2 MsgFromFriends = 4 )
const ( PostSrc_VK = "vk" PostSrc_Widget = "widget" PostSrc_Api = "api" PostSrc_Rss = "rss" PostSrc_Sms = "sms" PostType_Post = "post" PostType_Suggest = "suggest" )
const ( JT_Join = "join" JT_Unsure = "unsure" JT_Accepted = "accepted" JT_Approved = "approved" JT_Request = "request" )
const ( ScopeNotify = Scope(1) ScopeFriends = Scope(2) ScopePhotos = Scope(4) ScopeAudio = Scope(8) ScopeVideo = Scope(16) ScopeDocs = Scope(131072) ScopeNotes = Scope(2048) ScopePages = Scope(128) ScopeStatus = Scope(1024) ScopeOffers = Scope(32) ScopeQuestions = Scope(64) ScopeWall = Scope(8192) ScopeGroups = Scope(262144) ScopeMessages = Scope(4096) ScopeEmail = Scope(4194304) ScopeNotifications = Scope(524288) ScopeStats = Scope(1048576) ScopeAds = Scope(32768) ScopeOffline = Scope(65536) )
List of known access scopes from https://vk.com/dev/permissions
const ( VK_MAX_PHOTOS = 5 VK_MAX_AUDIOS = 1 VK_MAX_DOCS = 1 VK_MAX_VIDEOS = 1 )
const ( UnlinkPhoto = iota UnlinkDoc UnlinkVideo UnlinkAudio )
const ( NameCaseNom = "nom" NameCaseGen = "gen" NameCaseDat = "dat" NameCaseAcc = "acc" NameCaseIns = "ins" NameCaseAbl = "abl" )
const ( FieldPhotoId = "photo_id" FieldVerified = "verified" FieldBlacklisted = "blacklisted" FieldSex = "sex" FieldBirthDate = "bdate" FieldCity = "city" FieldCountry = "country" FieldHomeTown = "home_town" FieldPhoto50 = "photo_50" FieldPhoto100 = "photo_100" FieldPhoto200 = "photo_200" FieldPhoto200Orig = "photo_200_orig" FieldPhoto400Orig = "photo_400_orig" FieldPhotoMax = "photo_max" FieldPhotoMaxOrig = "photo_max_orig" FieldOnline = "online" FieldLists = "lists" FieldDomain = "domain" FieldHasMobile = "has_mobile" FieldContacts = "contacts" FieldSite = "site" FieldEducation = "education" FieldUniversities = "universities" FieldSchools = "schools" FieldStatus = "status" FieldLastSeen = "last_seen" FieldFollowersCount = "followers_count" FieldCommonCount = "common_count" FieldCounters = "counters" FieldOccupation = "occupation" FieldNickName = "nickname" FieldRelatives = "relatives" FieldRelation = "relation" FieldPersonal = "personal" FieldConnections = "connections" FieldExports = "exports" FieldWallComments = "wall_comments" FieldActivities = "activities" FieldInterests = "interests" FieldMusic = "music" FieldMovies = "movies" FieldTv = "tv" FieldBooks = "books" FieldGames = "games" FieldAbout = "about" FieldQuotes = "quotes" FieldCanPost = "can_post" FieldCanSeeAllPosts = "can_see_all_posts" FieldCanSeeAudio = "can_see_audio" FieldCanWritePrivate = "can_write_private_message" FieldTimeZone = "timezone" FieldScreenName = "screen_name" FieldMaidenName = "maiden_name" )
const ( SexUnknown = 0 SexFemale = 1 SexMale = 2 )
Variables ¶
var ( Debug = false // Version of VK API Version = "5.53" // APIURL is a base to make API calls APIURL = "https://api.vk.com/method/" // HTTPS defines if use https instead of http. 1 - use https. 0 - use http HTTPS = 1 )
var ( // NameCases is a list of name cases available for VK NameCases = []string{NameCaseNom, NameCaseGen, NameCaseDat, NameCaseAcc, NameCaseIns, NameCaseAbl} )
Functions ¶
func ClearCaptcha ¶
func ClearCaptcha()
func ElemInSlice ¶
ElemInSlice checks if element is in the slice
func NewDelayer ¶
func NewUnlinker ¶
func SetCaptcha ¶
func SetCaptcha(id, key string)
func SetServer ¶
SetServer will set the new URL for callback server. And automatically retry till it get status ok or failed. This is blocking call.
func UnlinkAttachments ¶
Types ¶
type API ¶
type API struct { AppID string Secret string Scope []Scope AccessToken string Expiry time.Time UserID string UserEmail string Raw []byte // contains filtered or unexported fields }
API holds data to use for communication
func (*API) AuthURL ¶
AuthURL generates URL to authenticate via OAuth. v support option 'responseTyp string' and 'groupId int' (sequence as shown). responseTyp can either be "token" and "code" where default is "code". 'groupId' is to generate URL for group authorization.
func (*API) Authenticate ¶
Authenticate with API
func (*API) NewSession ¶
type AccessToken ¶
type AccessToken struct { AccessToken string `json:"access_token"` ExpiresIn time.Duration `json:"expires_in"` UserID int `json:"user_id"` UserEmail string `json:"email"` Error string `json:"error"` ErrorDescription string `json:"error_description"` }
AccessToken response from VK
type Attachment ¶
type Attachment struct { Type string `json:"type"` Pl *Poll `json:"poll"` P *Photo `json:"photo"` S *Sticker `json:"sticker"` V *Video `json:"video"` A *Audio `json:"audio"` D *Doc `json:"doc"` G json.RawMessage `json:"geo"` }
func GetAttachment ¶
func GetAttachment(r []byte) (*Attachment, error)
Another approach to get the Attachment object from raw bytes string. r is considered given to this method.
func (*Attachment) Audio ¶
func (a *Attachment) Audio() (*Audio, error)
func (*Attachment) Doc ¶
func (a *Attachment) Doc() (*Doc, error)
func (*Attachment) Photo ¶
func (a *Attachment) Photo() (*Photo, error)
func (*Attachment) Poll ¶
func (a *Attachment) Poll() (*Poll, error)
func (*Attachment) Sticker ¶
func (a *Attachment) Sticker() (*Sticker, error)
func (*Attachment) UnmarshalJSON ¶
func (a *Attachment) UnmarshalJSON(b []byte) error
Implement json.Unmarshaler, so the parsing on Post can be parsed directly. TODO: use Decoder struct to implment attachment unmarshal.
func (*Attachment) Video ¶
func (a *Attachment) Video() (*Video, error)
Video will only retrieve the preview image of the video. Only direct authorization is allowed to get the whole video content from VK server.
type AttachmentUploader ¶
type AttachmentUploader interface { AddVideo(path, name string) AttachmentUploader AddPhoto(path, name string) AttachmentUploader AddPhotos([]string) AttachmentUploader AddAudio(path, name string) AttachmentUploader AddAudios([]string) AttachmentUploader AddDoc(path, name string) AttachmentUploader AddDocs([]string) AttachmentUploader Upload() (string, error) }
func NewAttachmentsUploader ¶
func NewAttachmentsUploader(sess *Session, gid int) AttachmentUploader
This is optimized for wall posting (comments too) attachments. Video and doc will be uploaded to user's video section and doc section to avoid appear in community video and doc section.
func NewCommunityPMUploader ¶
func NewCommunityPMUploader(user, group *Session, gid int) AttachmentUploader
NewCommunityPMUploader optimize for community PM file upload. Both user and group token are required as group token is used for upload photo through message upload server meanwhile user token is used for doc, video and audio. There isn't any message upload server for video or audio. Message doc upload API only work for non-public page community. Thus it'll not be used. Doc and video will use user token to upload with 0 group_id (default to user section) provide to the http client params. Audio will use user token to upload with group_id (but in the end it'll be uploaded to user section). Photo message upload server don't allow group_id param. Uploaded doc, video and audio will appear on user account doc, video and audio sections respectively and not in group. Use unlinker to unlink them after message with attachments have been sent out and processed properly (video need time to process).
type Audio ¶
type Audio struct { ReceiveContent Id int `json:"id"` Owner int `json:"owner_id"` Artist string `json:"artist"` Title string `json:"title"` Duration int `json:"duration"` // in sec // TODO: parse to time.Duration Url string `json:"url"` Lyrics int `json:"lyrics_id"` Album int `json:"album_id"` Genre int `json:"genre_id"` }
type Bool ¶
type Bool bool
Bool is a bool variable parsed from int
func (Bool) MarshalJSON ¶
func (*Bool) UnmarshalJSON ¶
type CBServerSettings ¶
CB for callback
type CBSettings ¶
type CBSettings struct { MsgNew Bool `json:"message_new"` WCNew Bool `json:"wall_reply_new"` WCEdit Bool `json:"wall_reply_edit"` BPNew Bool `json:"board_post_new"` BPEdit Bool `json:"board_post_edit"` BPDelete Bool `json:"board_post_delete"` BPRestore Bool `json:"board_post_restore"` PhotoNew Bool `json:"photo_new"` VideoNew Bool `json:"video_new"` AudioNew Bool `json:"audio_new"` PCNew Bool `json:"photo_comment_new"` VCNew Bool `json:"video_comment_new"` MCNew Bool `json:"market_comment_new"` GroupJoin Bool `json:"group_join"` GroupLeave Bool `json:"group_leave"` WPNew Bool `json:"wall_post_new"` }
CB for callback
type Comment ¶
type Comment struct { Id int `json:"id"` FromId int `json:"from_id"` Date int64 `json:"date"` Text string `json:"text"` ReplyToUid int `json:"reply_to_uid"` ReplyToCid int `json:"reply_to_cid"` Attachments []*Attachment `json:"attachments"` Likes struct { Count int `json:"count"` UserLikes Bool `json:"user_likes"` CanLike Bool `json:"can_like"` } `json:"likes"` PostOwnerId int `json:"post_owner_id"` PostId int `json:"post_id"` }
type EpochTime ¶
EpochTime is time in seconds. Use it to successfully parse with json
func (EpochTime) MarshalJSON ¶
MarshalJSON unix timestamp strings
func (*EpochTime) UnmarshalJSON ¶
UnmarshalJSON unix timestamp strings
type Error ¶
type Geo ¶
type Geo struct { Type string `json:"type"` Coor string `json:"coordinates"` Place struct { Id int `json:"id"` Title string `json:"title"` Latitude float32 `json:"latitude"` Longitude float32 `json:"longitude"` Created int64 `json:"created"` Icon string `json:"icon"` Country string `json:"country"` City string `json:"city"` } `json:"place"` Showmap Bool `json:"showmap"` }
type Group ¶
type Group struct { // default fields Id int `json:"id"` Name string `json:"name"` ScreenName string `json:"screen_name"` IsClosed Bool `json:"is_closed"` IsAdmin Bool `json:"is_admin"` AdminLvl int `json:"admin_level"` IsMember Bool `json:"is_member"` Type string `json:"type"` Photo string `json:"photo"` PhotoMedium string `json:"photo_medium"` PhotoBig string `json:"photo_big"` // optional fields City int `json:"city,omitempty"` Country int `json:"country,omitempty"` Place struct { Pid int `json:"pid"` Title string `json:"title"` Latitude float32 `json:"latitude"` Longitude float32 `json:"longitude"` Type string `json:"type"` Country int `json:"country"` City int `json:"city"` Address string `json:"address"` } `json:"place,omitempty"` Desc string `json:"description,omitempty"` Wiki string `json:"wiki_page,omitempty"` MembersCount int `json:"members_count,omitempty"` Counters json.RawMessage `json:"counters,omitempty"` // TODO: counters StartDate int64 `json:"start_date,omitempty"` EndDate int64 `json:"end_date,omitempty"` CanPost Bool `json:"can_post,omitempty"` CanSeeAllPosts Bool `json:"can_see_all_posts,omitempty"` Activity string `json:"activity,omitempty"` Status string `json:"status,omitempty"` Contacts string `json:"contacts,omitempty"` }
Group contains community information (https://vk.com/dev/fields_groups)
type GroupLeave ¶
type GroupLooper ¶
type GroupLooper interface { More() (*SmallGroup, error) Size() int }
func NewGroupLoop ¶
func NewGroupLoop(s *SmallGroups) GroupLooper
type IdList ¶
type IdList []int
IdList is a list of comma-separated ids
func (IdList) MarshalJSON ¶
func (*IdList) UnmarshalJSON ¶
type Message ¶
type Message struct { Id int `json:"id"` UserId int `json:"user_id"` Date int64 `json:"date"` ReadState Bool `json:"read_state"` Out Bool `json:"out"` Title string `json:"title"` Body string `json:"body"` Attachments []*Attachment `json:"attachments"` Emoji Bool `json:"emoji"` Deleted Bool `json:"deleted"` Fwd []*Message `json:"fwd_messages"` G *Geo `json:"geo"` // for group chat ChatId int `json:"chat_id"` ChatActive []int `json:"chat_active"` UsersCount int `json:"users_count"` AdminId int `json:"admin_id"` Photo50 string `json:"photo_50"` Photo100 string `json:"photo_100"` Photo200 string `json:"photo_200"` }
type NotifItem ¶
type NotifItem struct { Type string `json:"type"` Date int64 `json:"date"` Parent json.RawMessage `json:"parent,omitempty"` Feedback json.RawMessage `json:"feedback"` }
func (*NotifItem) FeedbackAsComment ¶
func (*NotifItem) FeedbackAsPost ¶
func (*NotifItem) FeedbackIsComment ¶
func (*NotifItem) ParentAsComment ¶
func (*NotifItem) ParentAsPost ¶
func (*NotifItem) ParentAsTopic ¶
func (*NotifItem) ParentIsComment ¶
type Notifications ¶
type Photo ¶
type Photo struct { ReceiveContent Id int `json:"id"` AlbumId int `json:"album_id"` OwnerId int `json:"owner_id"` 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"` Text string `json:"text"` Date int64 `json:"date"` AccessKey string `json:"access_key"` }
type PhotoObj ¶
type PhotoObj struct { Pid int `json:"pid"` Aid int `json:"aid"` // album ID OwnerId int `json:"owner_id"` Src string `json:"src"` SrcBig string `json:"src_big"` SrcSmall string `json:"src"` SrcxXBig string `json:"src_xbig"` SrcxXXBig string `json:"src_xxbig"` SrcxXXXBig string `json:"src_xxxbig"` Width int `json:"width"` Height int `json:"height"` Text string `json:"text"` Created int64 `json:"created"` }
type PlatformInfo ¶
PlatformInfo contains information about time and platform
type Poll ¶
type Poll struct { Id int `json:"id"` OwnerId int `json:"owner_id"` Created int64 `json:"created"` Question string `json:"question"` Votes int `json:"votes"` AnswerId int `json:"answer_id"` Answers []struct { Id int `json:"id"` Text string `json:"text"` Votes int `json:"votes"` Rate float32 `json:"rate"` } `json:"answers"` Anonymous int `json:"anonymous"` }
type Post ¶
type Post struct { Id int `json:"id"` FromId int `json:"from_id"` OwnerId int `json:"owner_id"` Date int64 `json:"date"` PostType string `json:"post_type"` Text string `json:"text"` CanEdit Bool `json:"can_edit"` CreatedBy int `json:"created_by"` CanDel Bool `json:"can_delete"` ReplyOwnerId int `json:"reply_owner_id"` ReplyPostId int `json:"reply_post_id"` FriendsOnly int `json:"friends_only"` Comments struct { Count int `json:"count"` CanPost Bool `json:"can_post"` } `json:"comments"` Likes struct { Count int `json:"count"` UserLikes Bool `json:"user_likes"` CanLike Bool `json:"can_like"` CanPublish Bool `json:"can_publish"` } `json:"likes"` Reposts struct { Count int `json:"count"` UserReposted Bool `json:"user_reposted"` } `json:"reposts"` PostSrc struct { Type string `json:"type"` Data string `json:"data"` } `json:"post_source"` Attachments []*Attachment `json:"attachments"` G *Geo `json:"geo"` SignerId int `json:"signer_id"` CopyHistory []Post `json:"copy_history"` CanPin Bool `json:"can_pin"` IsPinned Bool `json:"is_pinned"` }
type Receive ¶
type Receive struct {
// contains filtered or unexported fields
}
func (*Receive) ParseRequest ¶
func (rx *Receive) ParseRequest(r *http.Request) (res *ReceivedResult, err error)
ParseRequest function
type ReceiveContent ¶
type ReceiveContent string
func (ReceiveContent) Content ¶
func (r ReceiveContent) Content() (io.ReadCloser, error)
func (ReceiveContent) String ¶
func (r ReceiveContent) String() string
type ReceivedResult ¶
type ReceivedResult struct { Type string `json:"type"` Object json.RawMessage `json:"object"` GroupId int `json:"group_id"` Secret string `json:"secret"` }
ReceivedResult type
func ParseRequest ¶
func ParseRequest(r *http.Request) (res *ReceivedResult, err error)
func (*ReceivedResult) Audio ¶
func (rr *ReceivedResult) Audio() (*Audio, error)
func (*ReceivedResult) Board ¶
func (rr *ReceivedResult) Board() (*TopicComment, error)
func (*ReceivedResult) GetBoardDelete ¶
func (rr *ReceivedResult) GetBoardDelete() (*TopicDelete, error)
func (*ReceivedResult) GetGroupJoin ¶
func (rr *ReceivedResult) GetGroupJoin() (*GroupJoin, error)
func (*ReceivedResult) GetGroupLeave ¶
func (rr *ReceivedResult) GetGroupLeave() (*GroupLeave, error)
func (*ReceivedResult) PM ¶
func (rr *ReceivedResult) PM() (*Message, error)
func (*ReceivedResult) Photo ¶
func (rr *ReceivedResult) Photo() (*Photo, error)
func (*ReceivedResult) Video ¶
func (rr *ReceivedResult) Video() (*Video, error)
func (*ReceivedResult) WallComment ¶
func (rr *ReceivedResult) WallComment() (*Comment, error)
func (*ReceivedResult) WallPost ¶
func (rr *ReceivedResult) WallPost() (*Post, error)
type Relative ¶
type Relative struct { Id int `json:"id"` // negative id describes non-existing users (possibly prepared id if they will register) Type string `json:"type"` // like `parent`, `grandparent`, `sibling` Name string `json:"name,omitempty"` }
Relative contains information about relative to the user
type School ¶
type School struct { Id int `json:"id"` Country int `json:"country"` City int `json:"city"` Name string `json:"name"` YearFrom int `json:"year_from"` YearTo int `json:"year_to"` Class string `json:"class"` TypeStr string `json:"type_str,omitempty"` Speciality string `json:"speciality,omitempty"` }
School contains information about schools
type Session ¶
func NewSession ¶
func (*Session) AudioGetAlbums ¶
func (*Session) AudioGetFromAlbum ¶
func (*Session) AudioGetFromUser ¶
func (*Session) AudioSearch ¶
func (*Session) FriendsGet ¶
func (*Session) MsgsGet ¶
MsgsGet implements method https://vk.com/dev/messages.get
func (*Session) MsgsMarkAsRead ¶
MsgsMarkAsRead implements method https://vk.com/dev/messages.markAsRead
func (*Session) NotifGet ¶
func (s *Session) NotifGet(startFrm string, filters []string, start, end int64) (*Notifications, error)
NotifGet implements method https://vk.com/dev/notifications.get. start and end is start_time and end_time field respectively.
func (*Session) NotifMarkAsViewed ¶
NotifMarkAsViewed implements method https://vk.com/dev/notifications.markAsViewed
func (*Session) UploadAudio ¶
UploadAudio only support upload to user audio at the moment. No API for group audio upload. gid is ignored.
func (*Session) UploadDoc ¶
func (s *Session) UploadDoc(path string) (json.RawMessage, error)
UploadDocs only support upload to user docs at the moment. VK server disallow group docs upload. Only user token will work.
func (*Session) UploadDocToWall ¶
func (s *Session) UploadDocToWall(path string) (json.RawMessage, error)
UploadDocsToWall only support upload to user wall at the moment. VK server disallow group docs upload. Only user token will work.
func (*Session) UploadMultiAlbumPhotos ¶
func (*Session) UploadMultiAudios ¶
UploadMultiAudios upload multiple VK audio attachments. It may call multiple times of the API. ps is arary of path string and ns is the array of the file name respectively to ps. ns is optional and can be nil. ns must all end with dot extension format. VK only allow mp3 format to be uploaded as audio type.
func (*Session) UploadMultiDocs ¶
UploadMultiDocs upload multiple VK doc attachments. It may call multiple times of the API. ps is array of path string and ns is the array of the file name respectively to ps. ns is optional and can be nil. ns must all end with dot extension format.
func (*Session) UploadMultiPMPhotos ¶
UploadMultiPMPhotos upload multiple VK photo attachments. It may call multiple times of the API. ps is arary of path string and ns is the array of the file name respectively to ps. ns is optional and can be nil. These photos are meant for use in private message. ns must all end with dot extension format.
func (*Session) UploadMultiPhotos ¶
UploadMultiPhotos upload multiple VK photo attachments. It may call multiple times of the API. ps is arary of path string and ns is the array of the file name respectively to ps. ns is optional and can be nil. These photos are meant for use in wall though comment can be used too. ns must all end with dot extension format.
func (*Session) UploadMultiVideos ¶
UploadMultiVideos upload multiple VK video attachments. It may call multiple times of the API. ps is arary of path string and ns is the array of the file name respectively to ps. ns is optional and can be nil. ns must all end with dot extension format.
func (*Session) UploadMultiWallDocs ¶
func (*Session) UploadPhotosToAlbum ¶
UploadPhotosToAlbum upload photos to album - either community album or user album. ss are the path to the photo path. gid is the community id if community album is the destination and aid is the album id.
func (*Session) UploadPhotosToPM ¶
func (*Session) UploadPhotosToWall ¶
func (*Session) UsersGet ¶
UsersGet implements method http://vk.com/dev/users.get
func (*Session) UsersGetFollowers ¶
func (s *Session) UsersGetFollowers(user int, fields []string, nameCase string, offset, count int) ([]User, error)
UsersGetFollowers implements https://vk.com/dev/users.getFollowers
func (*Session) UsersIsAppUser ¶
UsersIsAppUser implements https://vk.com/dev/users.isAppUser
func (*Session) WallDelete ¶
func (*Session) WallPost ¶
Post wall to either user's wall or user's page (community) wall. Current arg wallOwnerOptions consist of 'idInt int' and 'isCommunity bool' options. idInt is the user ID or community ID. isCommunity is the flag to indicate if the idInt refering a normal user ID or community ID. m is the message that want to be posted on the wall. If wallOwnerOptions is not supplied then this will assume the current user owner of the session token. So, a group token will return error as only user token is valid for wall posting action.
func (*Session) WallPostEdit ¶
func (*Session) WallRestore ¶
type SmallGroup ¶
type SmallGroups ¶
type SmallGroups struct { Count int `json:"count"` Items []*SmallGroup `json:"items"` }
func (*SmallGroups) More ¶
func (s *SmallGroups) More() (*SmallGroup, error)
func (*SmallGroups) Size ¶
func (s *SmallGroups) Size() int
type SmallUsers ¶
type SmallUsers []SmallUser
type Sticker ¶
type Sticker struct { ReceiveContent Id int `json:"id"` ProductId int `json:"product_id"` Photo64 string `json:"photo_64"` Photo128 string `json:"photo_128"` Photo256 string `json:"photo_256"` Photo352 string `json:"photo_352"` Photo512 string `json:"photo_512"` Width int `json:"width"` Height int `json:"height"` }
type Topic ¶
type Topic struct { Id int `json:"id"` OwnerId int `json:"owner_id"` Title string `json:"title"` Created int64 `json:"created"` CreatedBy int `json:"created_by"` Updated int64 `json:"updated"` UpdatedBy int `json:"updated_by"` IsClosed Bool `json:"is_closed"` IsFixed Bool `json:"is_fixed"` Comments int `json:"comments"` }
type TopicComment ¶
type TopicComment struct { Id int `json:"id"` FromId int `json:"from_id"` Date int64 `json:"date"` Text string `json:"text"` TopicOwnerId int `json:"topic_owner_id"` TopicId int `json:"topic_id"` Attachments []*Attachment `json:"attachments"` Likes struct { Count int `json:"count"` UserLikes Bool `json:"user_likes"` CanLike Bool `json:"can_like"` } `json:"likes"` }
type TopicDelete ¶
type University ¶
type University 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"` }
University contains information about the university
type UploadAlbumPhotos ¶
type UploadAudios ¶
type UploadDocs ¶
type UploadDocs struct {
File string `json:"file"`
}
type UploadServer ¶
type UploadVideos ¶
type UploadWallPhotos ¶
type User ¶
type User struct { Id int `json:"id"` FirstName string `json:"first_name"` LastName string `json:"last_name"` Deactivated string `json:"deactivated"` Hidden Bool `json:"hidden"` PhotoId string `json:"photo_id,omitempty"` Verified Bool `json:"verified,omitempty"` Blacklisted Bool `json:"blacklisted,omitempty"` Sex int `json:"sex,omitempty"` Birthdate string `json:"bdate,omitempty"` City GeoPlace `json:"city,omitempty"` Country GeoPlace `json:"country,omitempty"` HomeTown string `json:"home_town,omitempty"` Photo50 string `json:"photo_50,omitempty"` Photo100 string `json:"photo_100,omitempty"` Photo200 string `json:"photo_200,omitempty"` Photo200Orig string `json:"photo_200_orig,omitempty"` Photo400Orig string `json:"photo_400_orig,omitempty"` PhotoMax string `json:"photo_max,omitempty"` PhotoMaxOrig string `json:"photo_max_orig,omitempty"` Online Bool `json:"online,omitempty"` OnlineMobile Bool `json:"online_mobile,omitempty"` OnlineApp Bool `json:"online_app,omitempty"` Lists []int `json:"lists,omitempty"` Domain string `json:"domain,omitempty"` HasMobile Bool `json:"has_mobile,omitempty"` Contacts struct { Mobile string `json:"mobile_phone,omitempty"` Home string `json:"home_phone,omitempty"` } `json:"contacts,omitempty"` Site string `json:"site,omitempty"` Education struct { University int `json:"university,omitempty"` UniversityName string `json:"university_name,omitempty"` Faculty int `json:"faculty,omitempty"` FacultyName string `json:"faculty_name,omitempty"` Graduation int `json:"graduation,omitempty"` } `json:"education,omitempty"` Universities []University `json:"universities,omitempty"` Schools []School `json:"schools,omitempty"` Status string `json:"status,omitempty"` StatusAudio interface{} `json:"status_audio,omitempty"` // TODO: status_audio LastSeen PlatformInfo `json:"last_seen,omitempty"` FollowersCount int `json:"followers_count,omitempty"` CommonCount int `json:"common_count,omitempty"` Counters struct { Albums int `json:"albums,omitempty"` Videos int `json:"videos,omitempty"` Audios int `json:"audios,omitempty"` Photos int `json:"photos,omitempty"` Notes int `json:"notes,omitempty"` Friends int `json:"friends,omitempty"` Groups int `json:"groups,omitempty"` OnlineFriends int `json:"online_friends,omitempty"` MutualFriends int `json:"mutual_friends,omitempty"` UserVideos int `json:"user_videos,omitempty"` Followers int `json:"followers,omitempty"` UserPhotos int `json:"user_photos,omitempty"` Subscriptions int `json:"subscriptions,omitempty"` } `json:"counters,omitempty"` Occupation struct { Type string `json:"type,omitempty"` Id int `json:"id,omitempty"` Name string `json:"name,omitempty"` } `json:"occupation,omitempty"` NickName string `json:"nickname"` Relatives []Relative `json:"relatives,omitempty"` Relation int `json:"relation,omitempty"` // TODO: constants for relation Personal struct { Political int `json:"political,omitempty"` Langs []string `json:"langs,omitempty"` Religion string `json:"religion,omitempty"` InspiredBy string `json:"inspired_by,omitempty"` PeopleMain int `json:"people_main,omitempty"` LifeMain int `json:"life_main,omitempty"` Smoking int `json:"smoking,omitempty"` Alcohol int `json:"alcohol,omitempty"` } `json:"personal,omitempty"` Connections interface{} `json:"connections,omitempty"` // TODO: connections Exports interface{} `json:"exports,omitempty"` // TODO: exports WallComments Bool `json:"wall_comments,omitempty"` Activities string `json:"activities,omitempty"` Interests string `json:"interests,omitempty"` Music string `json:"music,omitempty"` Movies string `json:"movies,omitempty"` Tv string `json:"tv,omitempty"` Books string `json:"books,omitempty"` Games string `json:"games,omitempty"` About string `json:"about,omitempty"` Quotes string `json:"quotes,omitempty"` CanPost Bool `json:"can_post,omitempty"` CanSeeAllPosts Bool `json:"can_see_all_posts,omitempty"` CanSeeAudio Bool `json:"can_see_audio,omitempty"` CanWritePrivate Bool `json:"can_write_private_message,omitempty"` TimeZone int `json:"timezone,omitempty"` ScreenName string `json:"screen_name,omitempty"` MaidenName string `json:"maiden_name,omitempty"` }
User contains user information (https://vk.com/dev/fields)
type Video ¶
type Video struct { ReceiveContent Id int `json:"id"` OwnerId int `json:"owner_id"` Title string `json:"title"` Duration int `json:"duration"` Description string `json:"description"` Date int64 `json:"date"` Views int `json:"views"` Comments int `json:"comments"` Photo130 string `json:"photo_130"` Photo320 string `json:"photo_320"` Photo800 string `json:"photo_800"` AccessKey string `json:"access_key"` CanEdit Bool `json:"can_edit"` CanAdd Bool `json:"can_add"` }
type VideoObj ¶
type VideoObj struct { Id int `json:"id"` Vid int `json:"vid"` OwnerId int `json:"owner_id"` Title string `json:"title"` Duration int `json:"duration"` Description string `json:"description"` Link string `json:"link"` Photo130 string `json:"photo_130"` Photo320 string `json:"photo_320"` Photo640 string `json:"photo_640"` Date int64 `json:"date"` AddDate int64 `json:"adding_date"` Views int `json:"views"` Player string `json:"player"` }