-
Notifications
You must be signed in to change notification settings - Fork 9
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
1 parent
5a6579d
commit 8901f2f
Showing
40 changed files
with
265 additions
and
71 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package api | ||
|
||
import ( | ||
"encoding/json" | ||
|
||
"github.com/XiaoMengXinX/Music163Api-Go/types" | ||
"github.com/XiaoMengXinX/Music163Api-Go/utils" | ||
) | ||
|
||
// ResourceShareAPI 分享资源 API | ||
const ResourceShareAPI = "/api/share/friends/resource" | ||
|
||
// resourceShareReq resourceShare API 的 body json | ||
type resourceShareReq struct { | ||
ResourceID int `json:"id"` | ||
ResourceType string `json:"type"` | ||
Msg string `json:"msg"` | ||
} | ||
|
||
// CreateResourceShareReqJson 创建 分享资源 请求json | ||
func CreateResourceShareReqJson(resourceID int, resourceType string, msg string) string { | ||
if resourceType == "" { | ||
resourceType = "song" | ||
} | ||
reqBody := resourceShareReq{ | ||
ResourceID: resourceID, | ||
ResourceType: resourceType, | ||
Msg: msg, | ||
} | ||
reqBodyJson, _ := json.Marshal(reqBody) | ||
return string(reqBodyJson) | ||
} | ||
|
||
// ShareResource 分享资源 | ||
// 参数说明: | ||
// ResourceID: 资源ID(歌曲,歌单,mv,电台,电台节目对应 id) | ||
// ResourceType: 资源类型,默认歌曲 song,可传 song,playlist,mv,djradio,djprogram | ||
// Msg: 内容,140 字限制,支持 emoji,@用户名 | ||
func ShareResource(data utils.RequestData, resourceID int, resourceType string, msg string) (result types.SendEventData, err error) { | ||
var options utils.EapiOption | ||
options.Path = ResourceShareAPI | ||
options.Url = "https://music.163.com/eapi/share/friends/resource" | ||
reqBodyJson := CreateResourceShareReqJson(resourceID, resourceType, msg) | ||
options.Json = reqBodyJson | ||
resBody, _, err := utils.ApiRequest(options, data) | ||
if err != nil { | ||
return result, err | ||
} | ||
err = json.Unmarshal([]byte(resBody), &result) | ||
result.RawJson = resBody | ||
return result, err | ||
} |
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,41 @@ | ||
package api | ||
|
||
import ( | ||
"encoding/json" | ||
|
||
"github.com/XiaoMengXinX/Music163Api-Go/types" | ||
"github.com/XiaoMengXinX/Music163Api-Go/utils" | ||
) | ||
|
||
// SongShareAPI 分享歌曲 API | ||
const SongShareAPI = "/api/music/songshare/share/property" | ||
|
||
// songShareReq SongShare API 的 body json | ||
type songShareReq struct { | ||
SongId int `json:"songId"` | ||
} | ||
|
||
// CreateSongShareReqJson 创建 分享歌曲 请求json | ||
func CreateSongShareReqJson(musicID int) string { | ||
reqBody := songShareReq{ | ||
SongId: musicID, | ||
} | ||
reqBodyJson, _ := json.Marshal(reqBody) | ||
return string(reqBodyJson) | ||
} | ||
|
||
// SongShare 分享歌曲,用于音乐人任务 | ||
func SongShare(data utils.RequestData, musicID int) (result types.SongShareData, err error) { | ||
var options utils.EapiOption | ||
options.Path = SongShareAPI | ||
options.Url = "https://music.163.com/eapi/song/share" | ||
reqBodyJson := CreateSongShareReqJson(musicID) | ||
options.Json = reqBodyJson | ||
resBody, _, err := utils.ApiRequest(options, data) | ||
if err != nil { | ||
return result, err | ||
} | ||
err = json.Unmarshal([]byte(resBody), &result) | ||
result.RawJson = resBody | ||
return result, err | ||
} |
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
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
Oops, something went wrong.