Skip to content

Commit

Permalink
Update ReadMe
Browse files Browse the repository at this point in the history
  • Loading branch information
boxie123 committed Dec 27, 2023
1 parent 795d180 commit 3562327
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 4 deletions.
34 changes: 34 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,36 @@
# BilibiliAuthorize
Go实现的Bilibili Api签名

## 使用
```
go get -u github.com/boxie123/BilibiliAuthorize
```

## 示例
```go
package main

import (
"fmt"
"github.com/boxie123/BilibiliAuthorize/web"
"github.com/boxie123/BilibiliAuthorize/app"
)

func main() {
param := map[string]interface{}{
"foo": "114",
"bar": "514",
"zab": 1919810,
}
param1 := web.ParamSign(param)
param2 := app.ParamSign(param)
fmt.Println(param1, param2)
}
```

## WARNING

- 本项目遵守 GPLv3 协议,如需使用、转载必须保留版权和许可声明并公开源码
- 请勿滥用,本项目仅用于学习和测试!请勿滥用,本项目仅用于学习和测试!请勿滥用,本项目仅用于学习和测试!
- 利用本项目提供的接口、文档等造成不良影响及后果与本人无关
- 本项目为开源项目,不接受任何形式的催单和索取行为,更不容许存在付费内容
6 changes: 5 additions & 1 deletion app/param.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ const (
MobiApp = "android"
)

// ParamSign 为参数添加 appkey 和 sign
// ParamSign
//
// @Description: 向参数映射中添加 appkey 和 sign 鉴权签名
// @param param 需要加签名的参数映射
// @return map[string]interface{}
func ParamSign(param map[string]interface{}) map[string]interface{} {
_, ok := param["appkey"]
if !ok {
Expand Down
1 change: 0 additions & 1 deletion main.go

This file was deleted.

10 changes: 8 additions & 2 deletions web/wbi.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ func getTokenFromUrl(wbiUrl string) string {
return key
}

// UpdateWbiKey 更新缓存中的 img_key 和 sub_key
// UpdateWbiKey
//
// @Description: 更新缓存中的 wbi 鉴权所需参数 img_key 和 sub_key
func UpdateWbiKey() {
resp, err := http.Get("https://api.bilibili.com/x/web-interface/nav")
if err != nil {
Expand Down Expand Up @@ -81,7 +83,11 @@ func getMixinKey(orig string) string {
return str.String()[:32]
}

// ParamSign 为参数添加 wts 和 w_rid
// ParamSign
//
// @Description: 向参数映射中添加 wts 和 w_rid 鉴权签名
// @param param 需要加签名的参数映射
// @return map[string]interface{}
func ParamSign(param map[string]interface{}) map[string]interface{} {
_, ok := param["wts"]
if !ok {
Expand Down

0 comments on commit 3562327

Please sign in to comment.