-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
syd
committed
Apr 16, 2024
1 parent
5de8080
commit 57b01dd
Showing
10 changed files
with
349 additions
and
146 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package main | ||
|
||
import ( | ||
"bytes" | ||
"fmt" | ||
"log" | ||
|
||
sdk "github.com/bububa/WeWorkFinanceSDK" | ||
) | ||
|
||
func main() { | ||
// CorpId 企业ID | ||
corpId := "wwd08c8e7c775ab44d" | ||
corpSecret := "zJ6k0naVVQ--gt9PUSSEvs03zW_nlDVmjLCTOTAfrew" | ||
clt, err := sdk.NewClient(corpId, corpSecret) | ||
if err != nil { | ||
log.Fatalln(err) | ||
} | ||
defer clt.Destroy() | ||
var ( | ||
seq uint64 | ||
limit uint64 = 1000 | ||
proxy = "" | ||
passwd = "" | ||
timeout = 300 | ||
) | ||
for { | ||
chatsData, err := clt.GetChatData(seq, limit, proxy, passwd, timeout) | ||
if err != nil { | ||
log.Fatalln(err) | ||
} | ||
if len(chatsData) == 0 { | ||
break | ||
} | ||
// iterate chatsData | ||
for _, data := range chatsData { | ||
// update seq with chatdata.Seq for next loop | ||
seq = data.Seq | ||
// decrypt chat data | ||
msg, err := clt.DecryptData(data.EncryptRandomKey, data.EncryptChatMsg) | ||
if err != nil { | ||
log.Fatalln(err) | ||
continue | ||
} | ||
fmt.Printf("msg: %+v\n", msg) | ||
if msg.MessageType() == sdk.IMG_MSG { | ||
var ( | ||
w = new(bytes.Buffer) | ||
sdkField = msg.(sdk.ImageMessage).SdkFileId | ||
) | ||
err := clt.DownloadMedia(w, sdkField, proxy, passwd, timeout) | ||
if err != nil { | ||
log.Fatalln(err) | ||
continue | ||
} | ||
log.Printf("download mediadata, len:%d bytes\n", w.Len()) | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
module github.com/bububa/WeWorkFinanceSDK | ||
|
||
go 1.18 | ||
go 1.20 |
Oops, something went wrong.