提交 df257cde 编写于 作者: B binaryify

新增发送私信相关接口

上级 97b6e5d6
# 更新日志
### 2.9.5 | 2018.05.08
新增发送私信相关接口
### 2.9.4 | 2018.05.04
新增热搜接口,更新 banner 接口
......
......@@ -185,6 +185,12 @@ app.use("/search/multimatch", require("./router/search_multimatch"));
// 搜索 suggest,搜索结果包含单曲,歌手,歌单,mv信息
app.use("/search/suggest", require("./router/search_suggest"));
// 发送私信
app.use("/send/text", require("./router/send_text"));
// 发送私信(歌单)
app.use("/send/playlist", require("./router/send_playlist"));
//simi ,相似歌单
app.use("/simi/playlist", require("./router/simi_playlist"));
......@@ -256,10 +262,6 @@ app.use("/user/subcount", require("./router/user_subcount"));
app.use("/user/record", require("./router/user_playrecord"));
app.use("/send/text", require("./router/send_text"));
app.use("/send/playlist", require("./router/send_playlist"));
const port = process.env.PORT || 3000;
app.listen(port, () => {
......
......@@ -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&timestamp=1503019930000`
* 如果是跨域请求 , 请在所有请求带上 `xhrFields: { withCredentials: true }` 否则
可能会因为没带上 cookie 导致 301, 具体例子可看 `public/test.html`, 例子使用
jquery, axios 版本也类似
* 301 错误基本都是没登录就调用了需要登录的接口 , 如果登陆了还是提示 301, 基本都
是缓存把数据缓存起来了 , 解决方法是等待 2 分钟或者重启服务重新登录后再调用接口
!> 如果是跨域请求 , 请在所有请求带上 `xhrFields: { withCredentials: true }` 否则
可能会因为没带上 cookie 导致 301, 具体例子可看 `public/test.html`, 例子使用 jquery, axios 版本也类似
* 部分接口如登录接口不能调用太频繁 , 否则可能会触发 503 错误或者 ip 高频错误 ,
若需频繁调用 , 需要准备 IP 代理池 .
!> 301 错误基本都是没登录就调用了需要登录的接口,如果登陆了还是提示 301, 基本都是缓存把数据缓存起来了,解决方法是等待 2 分钟或者重启服务重新登录后再调用接口
* 本项目仅供学习使用 , 文档可能会有缓存 , 如果文档版本和 github 上的版本不一致 ,
请清除缓存再查看
!> 部分接口如登录接口不能调用太频繁 , 否则可能会触发 503 错误或者 ip 高频错误 ,若需频繁调用 , 需要准备 IP 代理池 (更新:已加入缓存机制,但仍需注意).
* 2.5.0 版本对部分原有 api 做了微调 , 不过只是调整了下地址 , 参数和返回结果不受
影响
!> 本项目仅供学习使用 , 文档可能会有缓存 , 如果文档版本和 github 上的版本不一致,请清除缓存再查看
* 由于网易限制 , 此项目在国外服务器上使用会受到限制 , 如需解决 , 可使用大陆服务
器或者使用代理 , 感谢 [@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, 可以获取用户电台
......
{
"name": "NeteaseCloudMusicApi",
"version": "2.9.4",
"version": "2.9.5",
"description": "网易云音乐 NodeJS 版 API",
"scripts": {
"start": "node app.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(
......
......@@ -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`,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册