Skip to content

Commit

Permalink
增加每日积分获取
Browse files Browse the repository at this point in the history
  • Loading branch information
happy888888 committed Dec 19, 2020
1 parent 7392157 commit 7e1434e
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ WeiboTask

### 💥主要功能
* [x] 微博超话签到
* [ ] 每日积分获取

</br>

Expand Down
32 changes: 32 additions & 0 deletions src/WeiboClient/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ package WeiboClient
import (
"encoding/json"
"io/ioutil"
"net/http"
"strings"
)

// @title GeneralButton
Expand Down Expand Up @@ -70,3 +72,33 @@ func (w *WeiboClient) ContainerGetIndex(id string, sinceId string) (map[string]i
}
return data, nil
}

// @title SuperReceiveScore
// @description 超话每日积分获取
// @auth 星辰
// @param
// @return map[string]interface{} 接口返回值
func (w *WeiboClient) SuperReceiveScore() (map[string]interface{}, error){
req, err := http.NewRequest("POST",
"https://huati.weibo.cn/aj/super/receivescore",
strings.NewReader("type=REQUEST&user_score=999"),
)
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
req.Header.Set("Referer", "https://huati.weibo.cn/")
req.Header.Set("X-Requested-With", "XMLHttpRequest")
resp, err := w.client.Do(req)
if err != nil {
return nil, err
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
return nil, err
}
var data map[string]interface{}
err = json.Unmarshal(body, &data)
if err != nil {
return nil, err
}
return data, nil
}
34 changes: 34 additions & 0 deletions src/WeiboTask/Tasks/ReceiveScore.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// @Title ReceiveScore
// @Description 每日积分获取
// @Author 星辰
// @Update
package Tasks

import (
"WeiboClient"
"log"
"sync"
)

// @title ReceiveScore
// @description 每日积分获取
// @auth 星辰
// @param w *WeiboClient.WeiboClient 微博客户端
// @param wg *sync.WaitGroup 等待组,保持程序同步
// @return
func ReceiveScore(w *WeiboClient.WeiboClient, wg *sync.WaitGroup) {
if wg != nil {
defer wg.Done()
}
data, err := w.SuperReceiveScore()
if err != nil {
log.Println("每日积分获取异常:"+err.Error())
return
}
if data["code"] == "100000" {
data = data["data"].(map[string]interface{})
log.Println("每日积分获取增加:"+data["add_score"].(string)+"积分")
}else{
log.Println("每日积分获取失败:"+data["msg"].(string))
}
}
3 changes: 2 additions & 1 deletion src/WeiboTask/runTasks.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ import (
// @return
func runTasks(w *WeiboClient.WeiboClient) {
var mywg sync.WaitGroup
mywg.Add(1)
mywg.Add(2)
go Tasks.SuperCheckIn(w, &mywg)
go Tasks.ReceiveScore(w, &mywg)
mywg.Wait()
}

0 comments on commit 7e1434e

Please sign in to comment.