Skip to content

Commit

Permalink
Merge pull request #9 from rxrw/master
Browse files Browse the repository at this point in the history
  • Loading branch information
happy888888 authored Apr 7, 2021
2 parents 57ce9aa + 3fc5a84 commit b874c65
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 16 deletions.
3 changes: 2 additions & 1 deletion config.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@
}
],
"C": "android",
"S": ""
"S": "",
"F": ""
}
4 changes: 3 additions & 1 deletion src/WeiboClient/WeiboClient.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ type WeiboClient struct{
client *http.Client
C string
S string
F string
}

// @title init
Expand All @@ -37,10 +38,11 @@ func (w *WeiboClient) init() {
// @description 创建一个WeiboClient对象并初始化
// @auth 星辰
// @return WeiboClient对象
func New(c string, s string) *WeiboClient {
func New(c string, s string, f string) *WeiboClient {
ret := new(WeiboClient)
ret.init()
ret.C = c
ret.S = s
ret.F = f
return ret
}
24 changes: 12 additions & 12 deletions src/WeiboClient/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ func (w *WeiboClient) UrlSafe() (map[string]interface{}, error){
resp, err := w.client.Get("https://api.weibo.cn/2/client/url_safe"+
"?c="+w.C+
"&s="+w.S+
"&from="+"10AC395010"+
"&from="+w.F+
"&gsid="+w.getCookie("SUB", ".weibo.cn"),
)
if err != nil {
Expand Down Expand Up @@ -334,7 +334,7 @@ func (w *WeiboClient) CardList(containerid string) (map[string]interface{}, erro
resp, err := w.client.Get("https://api.weibo.cn/2/cardlist"+
"?c="+w.C+
"&s="+w.S+
"&from="+"10AC395010"+
"&from="+w.F+
"&gsid="+w.getCookie("SUB", ".weibo.cn")+
"&page="+"1"+
"&count="+"20"+
Expand Down Expand Up @@ -369,7 +369,7 @@ func (w *WeiboClient) AppRepost(id string) (map[string]interface{}, error){
"share_source":"0",
"is_fast":"1",
"gsid":w.getCookie("SUB", ".weibo.cn"),
"from":"10AC395010",
"from":w.F,
}
var b bytes.Buffer
wt := multipart.NewWriter(&b)
Expand All @@ -391,7 +391,7 @@ func (w *WeiboClient) AppRepost(id string) (map[string]interface{}, error){
"?c="+w.C+
"&s="+w.S+
"&id="+id+
"&from="+"10AC395010"+
"&from="+w.F+
//"&gsid="+w.getCookie("SUB", ".weibo.cn"),
"&gsid="+bodyMap["gsid"],
&b,
Expand Down Expand Up @@ -424,7 +424,7 @@ func (w *WeiboClient) AppDestroy(id string) (map[string]interface{}, error){
"?c="+w.C+
"&s="+w.S+
"&id="+id+
"&from="+"10AC395010"+
"&from="+w.F+
"&gsid="+w.getCookie("SUB", ".weibo.cn"),
)
if err != nil {
Expand Down Expand Up @@ -476,7 +476,7 @@ func (w *WeiboClient) AppCommentsCreate(id string, content string) (map[string]i
"&s="+w.S+
"&fromlog="+"100016356549855"+
"&featurecode="+"10000001"+
"&from="+"10AC395010"+
"&from="+w.F+
"&lfid="+"guanzhu"+
"&gsid="+w.getCookie("SUB", ".weibo.cn"),
&b,
Expand Down Expand Up @@ -509,7 +509,7 @@ func (w *WeiboClient) AppCommentsDestroy(id string) (map[string]interface{}, err
"?c="+w.C+
"&s="+w.S+
"&cid="+id+
"&from="+"10AC395010"+
"&from="+w.F+
"&gsid="+w.getCookie("SUB", ".weibo.cn"),
)
if err != nil {
Expand Down Expand Up @@ -542,7 +542,7 @@ func (w *WeiboClient) AppFriendshipsCreate(id string) (map[string]interface{}, e
"&invite="+"0"+
"&able_recommend="+"0"+
"&featurecode="+"10000326"+
"&from="+"10AC395010"+
"&from="+w.F+
"&gsid="+w.getCookie("SUB", ".weibo.cn"),
)
if err != nil {
Expand Down Expand Up @@ -573,7 +573,7 @@ func (w *WeiboClient) AppFriendshipsDestroy(id string) (map[string]interface{},
"&uid="+id+
"&trim_level="+"0"+
"&trim="+"1"+
"&from="+"10AC395010"+
"&from="+w.F+
"&gsid="+w.getCookie("SUB", ".weibo.cn"),
)
if err != nil {
Expand Down Expand Up @@ -603,7 +603,7 @@ func (w *WeiboClient) AppSetLike(id string) (map[string]interface{}, error){
"&s="+w.S+
"&id="+id+
"&sourcetype="+"feed"+
"&from="+"10AC395010"+
"&from="+w.F+
"&gsid="+w.getCookie("SUB", ".weibo.cn"),
)
if err != nil {
Expand Down Expand Up @@ -633,7 +633,7 @@ func (w *WeiboClient) AppCancelLike(id string) (map[string]interface{}, error){
"&s="+w.S+
"&id="+id+
"&sourcetype="+"feed"+
"&from="+"10AC395010"+
"&from="+w.F+
"&gsid="+w.getCookie("SUB", ".weibo.cn"),
)
if err != nil {
Expand Down Expand Up @@ -665,7 +665,7 @@ func (w *WeiboClient) UnreadFriendsTimeline() (map[string]interface{}, error){
"&featurecode="+"10000001"+
"&c="+w.C+
"&s="+w.S+
"&from="+"10AC395010"+
"&from="+w.F+
"&lfid="+"guanzhu"+
"&gsid="+w.getCookie("SUB", ".weibo.cn"),
strings.NewReader("since_id=0"),
Expand Down
3 changes: 2 additions & 1 deletion src/WeiboTask/Tasks/SuperCheckIn.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ func GetSuperTopics(w *WeiboClient.WeiboClient, ch chan<- [2]string) {
break
}
//python里直接["data"]["cardlistInfo"]["since_id"]
sinceId, ok := data["data"].(map[string]interface{})["cardlistInfo"].(map[string]interface{})["since_id"]
var ok bool
sinceId, ok = data["data"].(map[string]interface{})["cardlistInfo"].(map[string]interface{})["since_id"].(string)
if !ok {
log.Println("获取超话列表sinceId错误")
break
Expand Down
2 changes: 1 addition & 1 deletion src/WeiboTask/WeiboTask.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func runOnce(reloadConfig bool) {
}
}
defer sendToServerChan()
wb := WeiboClient.New(MyConfig.C, MyConfig.S)
wb := WeiboClient.New(MyConfig.C, MyConfig.S, MyConfig.F)
if wb.LoginByCookies(MyConfig.Cookies) {
defer func() { MyConfig.Cookies = wb.GetCookies(); _ = SaveConfig() }()
runTasks(wb)
Expand Down
1 change: 1 addition & 0 deletions src/WeiboTask/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ type Config struct{
Stime [2]int //定时启动时间,格式为{小时, 分钟}
C string //平台,如"android"
S string //app秘钥,6位字符串
F string //app from参数,8位字符串
}

var MyConfig Config //配置文件对象
Expand Down

0 comments on commit b874c65

Please sign in to comment.