diff --git a/CHANGELOG.MD b/CHANGELOG.MD index ad01de0..e6b8ae5 100644 --- a/CHANGELOG.MD +++ b/CHANGELOG.MD @@ -1,4 +1,7 @@ # 更新日志 +### 2.9.5 | 2018.05.08 +新增发送私信相关接口 + ### 2.9.4 | 2018.05.04 新增热搜接口,更新 banner 接口 diff --git a/app.js b/app.js index db087d9..62c22f7 100644 --- a/app.js +++ b/app.js @@ -185,6 +185,9 @@ app.use("/search/multimatch", require("./router/search_multimatch")); // 搜索 suggest,搜索结果包含单曲,歌手,歌单,mv信息 app.use("/search/suggest", require("./router/search_suggest")); + + + //simi ,相似歌单 app.use("/simi/playlist", require("./router/simi_playlist")); diff --git a/docs/README.md b/docs/README.md index 8fb4789..120557d 100644 --- a/docs/README.md +++ b/docs/README.md @@ -16,6 +16,9 @@ ## 版本新特性 +### 2.9.5 | 2018.05.08 +新增发送私信相关接口 + ### 2.9.4 | 2018.05.04 新增热搜接口,更新 banner 接口 @@ -121,6 +124,8 @@ banner 接口 , 增加刷新登录接口 , 增加电台相关接口 , 补充评 61. 给评论点赞 62. 获取动态 63. 获取热搜 +64. 发送私信 +65. 发送私信歌单 ## 安装 @@ -192,33 +197,23 @@ docker run -d -p 3000:3000 --name netease-cloud-music -e http_proxy= -e https_pr ### 调用前须知 -* 为使用方便 , 降低门槛 , 登录接口直接使用了 get 明文请求 , 请按实际需求对源码修 - 改 +!> 为使用方便,降低门槛,登录接口直接使用了 get 明文请求,请按实际需求对源码修改 -* 由于接口做了缓存处理 ( 缓存 2 分钟 , 可在 app.js 设置 , 可能会导致登陆后获取不 +!> 由于接口做了缓存处理 ( 缓存 2 分钟 , 可在 app.js 设置 , 可能会导致登陆后获取不 到 cookie), 相同的 url 会在两分钟内只向网易服务器发一次请求 , 如果遇到不需要缓 存结果的接口 , 可在请求 url 后面加一个时间戳参数使 url 不同 , 例子 : `/simi/playlist?id=347230×tamp=1503019930000` -* 如果是跨域请求 , 请在所有请求带上 `xhrFields: { withCredentials: true }` 否则 - 可能会因为没带上 cookie 导致 301, 具体例子可看 `public/test.html`, 例子使用 - jquery, axios 版本也类似 +!> 如果是跨域请求 , 请在所有请求带上 `xhrFields: { withCredentials: true }` 否则 + 可能会因为没带上 cookie 导致 301, 具体例子可看 `public/test.html`, 例子使用 jquery, axios 版本也类似 -* 301 错误基本都是没登录就调用了需要登录的接口 , 如果登陆了还是提示 301, 基本都 - 是缓存把数据缓存起来了 , 解决方法是等待 2 分钟或者重启服务重新登录后再调用接口 +!> 301 错误基本都是没登录就调用了需要登录的接口,如果登陆了还是提示 301, 基本都是缓存把数据缓存起来了,解决方法是等待 2 分钟或者重启服务重新登录后再调用接口 -* 部分接口如登录接口不能调用太频繁 , 否则可能会触发 503 错误或者 ip 高频错误 , - 若需频繁调用 , 需要准备 IP 代理池 . +!> 部分接口如登录接口不能调用太频繁 , 否则可能会触发 503 错误或者 ip 高频错误 ,若需频繁调用 , 需要准备 IP 代理池 (更新:已加入缓存机制,但仍需注意). -* 本项目仅供学习使用 , 文档可能会有缓存 , 如果文档版本和 github 上的版本不一致 , - 请清除缓存再查看 +!> 本项目仅供学习使用 , 文档可能会有缓存 , 如果文档版本和 github 上的版本不一致,请清除缓存再查看 -* 2.5.0 版本对部分原有 api 做了微调 , 不过只是调整了下地址 , 参数和返回结果不受 - 影响 - -* 由于网易限制 , 此项目在国外服务器上使用会受到限制 , 如需解决 , 可使用大陆服务 - 器或者使用代理 , 感谢 [@hiyangguo](https://github.com/hiyangguo)提出 - 的[解决方法](https://github.com/Binaryify/NeteaseCloudMusicApi/issues/29#issuecomment-298358438), +!> 由于网易限制,此项目在国外服务器上使用会受到限制,如需解决 , 可使用大陆服务器或者使用代理 , 感谢 [@hiyangguo](https://github.com/hiyangguo)提出的[解决方法](https://github.com/Binaryify/NeteaseCloudMusicApi/issues/29#issuecomment-298358438): 在 'util.js' 的 'headers' 处增加 `X-Real-IP':'211.161.244.70' // 任意国内 IP` 即可解决 @@ -291,6 +286,40 @@ Cookies 返回数据如下图 : ![用户歌单](https://raw.githubusercontent.com/Binaryify/NeteaseCloudMusicApi/master/static/%E7%94%A8%E6%88%B7%E6%AD%8C%E5%8D%95.png) +### 发送私信 + +说明 : 登陆后调用此接口 , 传入用户 id 和要发送的信息, 可以发送私信,返回内容为历史私信,包含带歌单的私信信息(注:不能发送私信给自己) + +**必选参数 :** + +`user_ids` : 用户 id,多个需用逗号隔开 + +`msg` : 要发送的信息 + + +**接口地址 :** `/send/text` + +**调用例子 :** `/send/text?user_ids=32953014&msg=test`,`/send/text?user_ids=32953014,475625142&msg=test` +返回数据如下图: +![数据](https://ws1.sinaimg.cn/large/006tKfTcgy1fr3p3hfeudj31kw1aek2e.jpg) + +### 发送私信(带歌单) + +说明 : 登陆后调用此接口 , 传入用户 id 和要发送的信息和歌单 id, 可以发送带歌单的私信(注:不能发送重复的歌单) + +**必选参数 :** + +`user_ids` : 用户 id,多个需用逗号隔开 + +`msg` : 要发送的信息 + + +**接口地址 :** `/send/playlist` + +**调用例子 :** `/send/playlist?msg=test&user_ids=475625142&playlist=705123491`,`/send/playlist?msg=test2&user_ids=475625142,32953014&playlist=705123493` +返回数据如下图: +![数据](https://ws1.sinaimg.cn/large/006tKfTcgy1fr3p1z7qmcj30v409adg5.jpg) + ### 获取用户电台 说明 : 登陆后调用此接口 , 传入用户 id, 可以获取用户电台 @@ -602,7 +631,7 @@ mp3url 不能直接用 , 可通过 `/music/url` 接口传入歌曲 id 获取具 ### 获取歌曲详情 -说明 : 调用此接口 , 传入音乐 id, 可获得歌曲详情 +说明 : 调用此接口 , 传入音乐 id, 可获得歌曲详情(注意:歌曲封面现在需要通过专辑内容接口获取) **必选参数 :** `ids`: 音乐 id, 如 `ids=347230` diff --git a/package.json b/package.json index 35e2fce..ef6483a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "NeteaseCloudMusicApi", - "version": "2.9.4", + "version": "2.9.5", "description": "网易云音乐 NodeJS 版 API", "scripts": { "start": "node app.js", diff --git a/router/send_playlist.js b/router/send_playlist.js index 73de626..3c52b31 100644 --- a/router/send_playlist.js +++ b/router/send_playlist.js @@ -9,7 +9,7 @@ router.get("/", (req, res) => { id: req.query.playlist, type: "playlist", msg: req.query.msg, - userIds: user_ids, + userIds: "[" + user_ids + "]", csrf_token: "" }; createWebAPIRequest( diff --git a/router/send_text.js b/router/send_text.js index 25e534d..f3485a0 100644 --- a/router/send_text.js +++ b/router/send_text.js @@ -9,9 +9,10 @@ router.get("/", (req, res) => { const data = { type: "text", msg: req.query.msg, - userIds: user_ids, + userIds: "[" + user_ids + "]", csrf_token: "" }; + console.log(data); createWebAPIRequest( "music.163.com", `/weapi/msg/private/send`,