tt/core/callapi_moment.go
2024-05-28 08:47:31 +08:00

447 lines
16 KiB
Go

package core
import "github.com/goWxHook/goWxHook/utils/json"
type GetMomentRequest struct {
MaxId string `json:"max_id"`
}
type GetMomentResponseData interface{}
type GetMomentResponse struct {
Data GetMomentResponseData `json:"data"`
Type int `json:"type"`
}
// GetMoment 获取朋友圈
func (w *WxApi) GetMoment(request GetMomentRequest) (GetMomentResponseData, error) {
resp, err := w.internalCall(MtGetMomentMsg, 60, MtGetMomentMsg, request, nil)
if err != nil {
return nil, err
}
var rdata GetMomentResponse
err = json.Unmarshal([]byte(resp), &rdata)
if err != nil {
return nil, WxError{-1, err.Error()}
}
return &rdata.Data, nil
}
type CommentMomentRequest struct {
ObjectId string `json:"object_id"`
Content string `json:"content"`
}
type CommentMomentResponseData struct {
BaseResponse struct {
ErrMsg struct {
} `json:"errMsg"`
Ret int `json:"ret"`
} `json:"baseResponse"`
SnsObject struct {
BlackList []interface{} `json:"blackList"`
BlackListCount int `json:"blackListCount"`
CommentCount int `json:"commentCount"`
CommentUserList []struct {
CommentFlag int `json:"commentFlag"`
CommentId int `json:"commentId"`
CommentId2 string `json:"commentId2"`
Content string `json:"content"`
CreateTime int `json:"createTime"`
DeleteFlag int `json:"deleteFlag"`
IsNotRichText int `json:"isNotRichText"`
Nickname string `json:"nickname"`
ReplyCommentId int `json:"replyCommentId"`
ReplyCommentId2 string `json:"replyCommentId2"`
ReplyUsername string `json:"replyUsername"`
Source int `json:"source"`
Type int `json:"type"`
Username string `json:"username"`
} `json:"commentUserList"`
CommentUserListCount int `json:"commentUserListCount"`
CreateTime int `json:"createTime"`
DeleteFlag int `json:"deleteFlag"`
ExtFlag int `json:"extFlag"`
GroupCount int `json:"groupCount"`
GroupList []interface{} `json:"groupList"`
GroupUser []interface{} `json:"groupUser"`
GroupUserCount int `json:"groupUserCount"`
Id string `json:"id"`
IsNotRichText int `json:"isNotRichText"`
LikeCount int `json:"likeCount"`
LikeFlag int `json:"likeFlag"`
LikeUserList []struct {
CommentFlag int `json:"commentFlag"`
CommentId int `json:"commentId"`
CommentId2 string `json:"commentId2"`
Content string `json:"content"`
CreateTime int `json:"createTime"`
DeleteFlag int `json:"deleteFlag"`
IsNotRichText int `json:"isNotRichText"`
Nickname string `json:"nickname"`
ReplyCommentId int `json:"replyCommentId"`
ReplyCommentId2 string `json:"replyCommentId2"`
ReplyUsername string `json:"replyUsername"`
Source int `json:"source"`
Type int `json:"type"`
Username string `json:"username"`
} `json:"likeUserList"`
LikeUserListCount int `json:"likeUserListCount"`
Nickname string `json:"nickname"`
NoChange int `json:"noChange"`
ObjectDesc struct {
Buffer string `json:"buffer"`
ILen int `json:"iLen"`
} `json:"objectDesc"`
ObjectOperations struct {
Buffer string `json:"buffer"`
ILen int `json:"iLen"`
} `json:"objectOperations"`
PreDownloadInfo struct {
NoPreDownloadRange string `json:"noPreDownloadRange"`
PreDownloadNetType int `json:"preDownloadNetType"`
PreDownloadPercent int `json:"preDownloadPercent"`
} `json:"preDownloadInfo"`
ReferId string `json:"referId"`
ReferUsername string `json:"referUsername"`
SnsRedEnvelops struct {
ReportId int `json:"reportId"`
ReportKey int `json:"reportKey"`
ResourceId int `json:"resourceId"`
RewardCount int `json:"rewardCount"`
RewardUserList []interface{} `json:"rewardUserList"`
} `json:"snsRedEnvelops"`
Username string `json:"username"`
WeAppInfo struct {
AppId int `json:"appId"`
MapPoiId string `json:"mapPoiId"`
RedirectUrl string `json:"redirectUrl"`
Score int `json:"score"`
ShowType int `json:"showType"`
UserName string `json:"userName"`
} `json:"weAppInfo"`
WithUserCount int `json:"withUserCount"`
WithUserList []interface{} `json:"withUserList"`
WithUserListCount int `json:"withUserListCount"`
} `json:"snsObject"`
}
type CommentMomentResponse struct {
Data CommentMomentResponseData `json:"data"`
Type int `json:"type"`
}
// CommentMoment 评论朋友圈
func (w *WxApi) CommentMoment(request CommentMomentRequest) (*CommentMomentResponseData, error) {
resp, err := w.internalCall(MtCommentMomentMsg, 60, MtCommentMomentMsg, request, nil)
if err != nil {
return nil, err
}
var rdata CommentMomentResponse
err = json.Unmarshal([]byte(resp), &rdata)
if err != nil {
return nil, WxError{-1, err.Error()}
}
return &rdata.Data, nil
}
type LikeMomentRequest struct {
ObjectId string `json:"object_id"`
}
type LikeMomentResponseData struct {
BaseResponse struct {
ErrMsg struct {
} `json:"errMsg"`
Ret int `json:"ret"`
} `json:"baseResponse"`
SnsObject struct {
BlackList []interface{} `json:"blackList"`
BlackListCount int `json:"blackListCount"`
CommentCount int `json:"commentCount"`
CommentUserList []struct {
CommentFlag int `json:"commentFlag"`
CommentId int `json:"commentId"`
CommentId2 string `json:"commentId2"`
Content string `json:"content"`
CreateTime int `json:"createTime"`
DeleteFlag int `json:"deleteFlag"`
IsNotRichText int `json:"isNotRichText"`
Nickname string `json:"nickname"`
ReplyCommentId int `json:"replyCommentId"`
ReplyCommentId2 string `json:"replyCommentId2"`
ReplyUsername string `json:"replyUsername"`
Source int `json:"source"`
Type int `json:"type"`
Username string `json:"username"`
} `json:"commentUserList"`
CommentUserListCount int `json:"commentUserListCount"`
CreateTime int `json:"createTime"`
DeleteFlag int `json:"deleteFlag"`
ExtFlag int `json:"extFlag"`
GroupCount int `json:"groupCount"`
GroupList []interface{} `json:"groupList"`
GroupUser []interface{} `json:"groupUser"`
GroupUserCount int `json:"groupUserCount"`
Id string `json:"id"`
IsNotRichText int `json:"isNotRichText"`
LikeCount int `json:"likeCount"`
LikeFlag int `json:"likeFlag"`
LikeUserList []struct {
CommentFlag int `json:"commentFlag"`
CommentId int `json:"commentId"`
CommentId2 string `json:"commentId2"`
Content string `json:"content"`
CreateTime int `json:"createTime"`
DeleteFlag int `json:"deleteFlag"`
IsNotRichText int `json:"isNotRichText"`
Nickname string `json:"nickname"`
ReplyCommentId int `json:"replyCommentId"`
ReplyCommentId2 string `json:"replyCommentId2"`
ReplyUsername string `json:"replyUsername"`
Source int `json:"source"`
Type int `json:"type"`
Username string `json:"username"`
} `json:"likeUserList"`
LikeUserListCount int `json:"likeUserListCount"`
Nickname string `json:"nickname"`
NoChange int `json:"noChange"`
ObjectDesc struct {
Buffer string `json:"buffer"`
ILen int `json:"iLen"`
} `json:"objectDesc"`
ObjectOperations struct {
Buffer string `json:"buffer"`
ILen int `json:"iLen"`
} `json:"objectOperations"`
PreDownloadInfo struct {
NoPreDownloadRange string `json:"noPreDownloadRange"`
PreDownloadNetType int `json:"preDownloadNetType"`
PreDownloadPercent int `json:"preDownloadPercent"`
} `json:"preDownloadInfo"`
ReferId string `json:"referId"`
ReferUsername string `json:"referUsername"`
SnsRedEnvelops struct {
ReportId int `json:"reportId"`
ReportKey int `json:"reportKey"`
ResourceId int `json:"resourceId"`
RewardCount int `json:"rewardCount"`
RewardUserList []interface{} `json:"rewardUserList"`
} `json:"snsRedEnvelops"`
Username string `json:"username"`
WeAppInfo struct {
AppId int `json:"appId"`
MapPoiId string `json:"mapPoiId"`
RedirectUrl string `json:"redirectUrl"`
Score int `json:"score"`
ShowType int `json:"showType"`
UserName string `json:"userName"`
} `json:"weAppInfo"`
WithUserCount int `json:"withUserCount"`
WithUserList []interface{} `json:"withUserList"`
WithUserListCount int `json:"withUserListCount"`
} `json:"snsObject"`
}
type LikeMomentResponse struct {
Data LikeMomentResponseData `json:"data"`
Type int `json:"type"`
}
// LikeMoment 点赞朋友圈
func (w *WxApi) LikeMoment(request LikeMomentRequest) (*LikeMomentResponseData, error) {
resp, err := w.internalCall(MtLikeMomentMsg, 60, MtLikeMomentMsg, request, nil)
if err != nil {
return nil, err
}
var rdata LikeMomentResponse
err = json.Unmarshal([]byte(resp), &rdata)
if err != nil {
return nil, WxError{-1, err.Error()}
}
return &rdata.Data, nil
}
type SendMomentRequest struct {
ObjectDesc string `json:"object_desc"`
}
type SendMomentResponseData struct {
BaseResponse struct {
ErrMsg struct {
} `json:"errMsg"`
Ret int `json:"ret"`
} `json:"baseResponse"`
SnsObject struct {
BlackList []interface{} `json:"blackList"`
BlackListCount int `json:"blackListCount"`
CommentCount int `json:"commentCount"`
CommentUserList []interface{} `json:"commentUserList"`
CommentUserListCount int `json:"commentUserListCount"`
CreateTime int `json:"createTime"`
DeleteFlag int `json:"deleteFlag"`
ExtFlag int `json:"extFlag"`
GroupCount int `json:"groupCount"`
GroupList []interface{} `json:"groupList"`
GroupUser []interface{} `json:"groupUser"`
GroupUserCount int `json:"groupUserCount"`
Id string `json:"id"`
IsNotRichText int `json:"isNotRichText"`
LikeCount int `json:"likeCount"`
LikeFlag int `json:"likeFlag"`
LikeUserList []interface{} `json:"likeUserList"`
LikeUserListCount int `json:"likeUserListCount"`
Nickname string `json:"nickname"`
NoChange int `json:"noChange"`
ObjectDesc struct {
Buffer string `json:"buffer"`
ILen int `json:"iLen"`
} `json:"objectDesc"`
ObjectOperations struct {
Buffer string `json:"buffer"`
ILen int `json:"iLen"`
} `json:"objectOperations"`
PreDownloadInfo struct {
NoPreDownloadRange string `json:"noPreDownloadRange"`
PreDownloadNetType int `json:"preDownloadNetType"`
PreDownloadPercent int `json:"preDownloadPercent"`
} `json:"preDownloadInfo"`
ReferId string `json:"referId"`
ReferUsername string `json:"referUsername"`
SnsRedEnvelops struct {
ReportId int `json:"reportId"`
ReportKey int `json:"reportKey"`
ResourceId int `json:"resourceId"`
RewardCount int `json:"rewardCount"`
RewardUserList []interface{} `json:"rewardUserList"`
} `json:"snsRedEnvelops"`
Username string `json:"username"`
WeAppInfo struct {
AppId int `json:"appId"`
MapPoiId string `json:"mapPoiId"`
RedirectUrl string `json:"redirectUrl"`
Score int `json:"score"`
ShowType int `json:"showType"`
UserName string `json:"userName"`
} `json:"weAppInfo"`
WithUserCount int `json:"withUserCount"`
WithUserList []interface{} `json:"withUserList"`
WithUserListCount int `json:"withUserListCount"`
} `json:"snsObject"`
SpamTips string `json:"spamTips"`
}
type SendMomentResponse struct {
Data SendMomentResponseData `json:"data"`
Type int `json:"type"`
}
// SendMoment 发送朋友圈
func (w *WxApi) SendMoment(request SendMomentRequest) (*SendMomentResponseData, error) {
resp, err := w.internalCall(MtSendMomentMsg, 60, MtSendMomentMsg, request, nil)
if err != nil {
return nil, err
}
var rdata SendMomentResponse
err = json.Unmarshal([]byte(resp), &rdata)
if err != nil {
return nil, WxError{-1, err.Error()}
}
return &rdata.Data, nil
}
type UploadMomentImageRequest struct {
Path string `json:"path"`
}
type UploadMomentImageResponseData struct {
BaseResponse struct {
Ret int `json:"ret"`
} `json:"baseResponse"`
BufferUrl struct {
Type int `json:"type"`
Url string `json:"url"`
} `json:"bufferUrl"`
ClientId string `json:"clientId"`
Id int `json:"id"`
StartPos int `json:"startPos"`
ThumbUrlCount int `json:"thumbUrlCount"`
ThumbUrls []struct {
Type int `json:"type"`
Url string `json:"url"`
} `json:"thumbUrls"`
TotalLen int `json:"totalLen"`
Type int `json:"type"`
}
type UploadMomentImageResponse struct {
Data UploadMomentImageResponseData `json:"data"`
Type int `json:"type"`
}
// UploadMomentImage 上传朋友圈图片
func (w *WxApi) UploadMomentImage(request UploadMomentImageRequest) (*UploadMomentImageResponseData, error) {
resp, err := w.internalCall(MtUploadMomentImageMsg, 60, MtUploadMomentImageMsg, request, nil)
if err != nil {
return nil, err
}
var rdata UploadMomentImageResponse
err = json.Unmarshal([]byte(resp), &rdata)
if err != nil {
return nil, WxError{-1, err.Error()}
}
return &rdata.Data, nil
}
type GetFriendMomentRequest struct {
Username string `json:"username"`
FirstPageMd5 string `json:"first_page_md5"`
MaxId string `json:"max_id"`
}
type GetFriendMomentResponseData struct {
BaseResponse struct {
ErrMsg struct {
} `json:"errMsg"`
Ret int `json:"ret"`
} `json:"baseResponse"`
ContinueId string `json:"continueId"`
FirstPageMd5 string `json:"firstPageMd5"`
LimitedId string `json:"limitedId"`
NewRequestTime int `json:"newRequestTime"`
ObjectCount int `json:"objectCount"`
ObjectCountForSameMd5 int `json:"objectCountForSameMd5"`
ObjectList []interface{} `json:"objectList"`
ObjectTotalCount int `json:"objectTotalCount"`
RetTips string `json:"retTips"`
ServerConfig struct {
CopyAndPasteWordLimit int `json:"copyAndPasteWordLimit"`
PostMentionLimit int `json:"postMentionLimit"`
} `json:"serverConfig"`
SnsUserInfo struct {
SnsBgImgId string `json:"snsBgImgId"`
SnsBgObjectId string `json:"snsBgObjectId"`
SnsFlag int `json:"snsFlag"`
SnsFlagEx int `json:"snsFlagEx"`
} `json:"snsUserInfo"`
}
type GetFriendMomentResponse struct {
Data GetFriendMomentResponseData `json:"data"`
Type int `json:"type"`
}
// GetFriendMoment 获取好友朋友圈
func (w *WxApi) GetFriendMoment(request GetFriendMomentRequest) (*GetFriendMomentResponseData, error) {
resp, err := w.internalCall(MtGetFriendMomentMsg, 60, MtGetFriendMomentMsg, request, nil)
if err != nil {
return nil, err
}
var rdata GetFriendMomentResponse
err = json.Unmarshal([]byte(resp), &rdata)
if err != nil {
return nil, WxError{-1, err.Error()}
}
return &rdata.Data, nil
}