https://github.com/tickstep/cloudpan189-api
cloudpan189 go api
https://github.com/tickstep/cloudpan189-api
Last synced: about 1 year ago
JSON representation
cloudpan189 go api
- Host: GitHub
- URL: https://github.com/tickstep/cloudpan189-api
- Owner: tickstep
- License: apache-2.0
- Created: 2020-08-26T14:22:50.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2023-11-16T02:20:37.000Z (over 2 years ago)
- Last Synced: 2025-04-16T02:08:48.681Z (about 1 year ago)
- Language: Go
- Size: 80.1 KB
- Stars: 38
- Watchers: 5
- Forks: 19
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# cloudpan189-api
GO语言封装的 cloud 189 天翼云盘接口API。可以基于该接口库实现对天翼云盘的二次开发。
[](https://pkg.go.dev/github.com/tickstep/cloudpan189-api?tab=doc)
[](https://raw.githubusercontent.com/modern-go/concurrent/master/LICENSE)
# 快速使用
导入包
```
import "github.com/tickstep/cloudpan189-api/cloudpan"
```
先调用登录接口,获取APP端cookie和WEB端cookie
```
appToken, e := cloudpan.AppLogin("193xxxxxx@189.cn", "123xxxxx")
if e != nil {
fmt.Println(e)
return
}
webToken := &cloudpan.WebLoginToken{}
webTokenStr := cloudpan.RefreshCookieToken(appToken.SessionKey)
if webTokenStr != "" {
webToken.CookieLoginUser = webTokenStr
}
fmt.Println("login success")
```
使用获取到的cookie创建PanClient实例
```
// pan client
panClient := cloudpan.NewPanClient(*webToken, *appToken)
```
调用PanClient相关方法可以实现对cloud189云盘的相关操作
```
// do get file info action
fi, err1 := panClient.FileInfoByPath("/我的文档")
if err1 != nil {
fmt.Println("get file info error")
return
}
fmt.Printf("name = %s, size = %d, path = %s", fi.FileName, fi.FileSize, fi.Path)
```