Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
彼暗flower
NeteaseCloudMusicApi
提交
34c92dde
N
NeteaseCloudMusicApi
项目概览
彼暗flower
/
NeteaseCloudMusicApi
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
N
NeteaseCloudMusicApi
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
34c92dde
编写于
5月 06, 2019
作者:
B
binaryify
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
更新文档
上级
d6ca1b5a
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
58 addition
and
45 deletion
+58
-45
docs/README.md
docs/README.md
+10
-8
public/test.html
public/test.html
+48
-37
未找到文件。
docs/README.md
浏览文件 @
34c92dde
...
...
@@ -211,22 +211,24 @@ $ sudo docker run -d -p 3000:3000 netease-music-api
## 接口文档
### 调用前须知
!> 本项目不提供线上 demo,请不要轻易信任使用他人提供的公开服务,以免发生安全问题,泄露自己的账号和密码
!> 为使用方便,降低门槛,
登录接口直接使用了 get 明文请求,请按实际需求对源码修改
!> 为使用方便,降低门槛,
文档示例接口直接使用了 GET 请求,本项目同时支持 GET/POST 请按实际需求使用
!> 由于接口做了缓存处理 ( 缓存 2 分钟,不缓存数据极容易引起网易服务器高频ip错误 , 可在 app.js 设置 , 可能会导致登陆后获取不
到 cookie), 相同的 url 会在两分钟内只向网易服务器发一次请求 , 如果遇到不需要缓
!> 由于接口做了缓存处理 ( 缓存 2 分钟,不缓存数据极容易引起网易服务器高频ip错误 , 可在 app.js 设置 , 可能会导致登陆后获取不到 cookie),
**相同的 url**
会在两分钟内只向网易服务器发一次请求 , 如果遇到不需要缓
存结果的接口 , 可在请求 url 后面加一个时间戳参数使 url 不同 , 例子 :
`/simi/playlist?id=347230×tamp=1503019930000`
`/simi/playlist?id=347230×tamp=1503019930000`
(之所以加入缓存机制是因为项目早期没有缓存机制,很多 issues 都是报 IP高频,请按自己需求改造缓存中间件(app.js),源码不复杂)
!> 如果是跨域请求 , 请在所有请求带上
`xhrFields: { withCredentials: true }`
否则
可能会因为没带上 cookie 导致 301, 具体例子可看
`public/test.html`
, 例子使用 jQuery
, axios 版本也类似
!> 如果是跨域请求 , 请在所有请求带上
`xhrFields: { withCredentials: true }`
(axios 为
`withCredentials: true`
)
否则
可能会因为没带上 cookie 导致 301, 具体例子可看
`public/test.html`
, 例子使用 jQuery
和 axios
!> 301 错误基本都是没登录就调用了需要登录的接口,如果登陆了还是提示 301, 基本都是缓存把数据缓存起来了,解决方法是
等待 2 分钟或者重启服务重新登录后再调用接口
!> 301 错误基本都是没登录就调用了需要登录的接口,如果登陆了还是提示 301, 基本都是缓存把数据缓存起来了,解决方法是
加时间戳或者等待 2 分钟或者重启服务重新登录后再调用接口,可自行改造缓存方法
!> 部分接口如登录接口不能调用太频繁 , 否则可能会触发 503 错误或者 ip 高频错误 ,若需频繁调用 , 需要准备 IP 代理池 (更新:已加入缓存机制,但仍需注意).
!> 本项目仅供学习使用 , 文档可能会有缓存 , 如果文档版本和 github 上的版本不一致,请清除缓存再查看
!> 本项目仅供学习使用,请尊重版权,请勿利用此项目从事商业行为
!> 文档可能会有缓存 , 如果文档版本和 github 上的版本不一致,请清除缓存再查看
!> 由于网易限制,此项目在国外服务器上使用会受到限制,如需解决 , 可使用大陆服务器或者使用代理 , 感谢
[
@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`
...
...
public/test.html
浏览文件 @
34c92dde
<!DOCTYPE html>
<html
lang=
"en"
>
<head>
<meta
charset=
"UTF-8"
/>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1.0"
/>
<meta
http-equiv=
"X-UA-Compatible"
content=
"ie=edge"
/>
<title>
test
</title>
</head>
<head>
<meta
charset=
"UTF-8"
>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1.0"
>
<meta
http-equiv=
"X-UA-Compatible"
content=
"ie=edge"
>
<title>
test
</title>
</head>
<body>
<script
src=
"https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"
></script>
<script
src=
"https://cdn.bootcss.com/axios/0.18.0/axios.min.js
"
></script>
<script>
$
.
ajax
({
url
:
"
http://localhost:3000/login/cellphone?phone=YOUR_PHONE&password=YOUR_PASSWORD
"
,
success
:
function
(
data
)
{
console
.
log
(
data
)
$
.
ajax
({
url
:
"
http://localhost:3000/recommend/resource
"
,
xhrFields
:
{
withCredentials
:
true
//关键
},
success
:
function
(
data
)
{
console
.
log
(
data
)
},
error
:
function
(
err
)
{
console
.
log
(
err
)
}
})
},
error
:
function
(
err
)
{
console
.
log
(
err
)
}
})
<body>
<script
src=
"https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"
></script>
<script>
$
.
ajax
({
url
:
"
http://localhost:3000/login/cellphone?phone=phone&password=password
"
,
xhrFields
:
{
withCredentials
:
true
},
success
:
function
(
data
)
{
console
.
log
(
data
)
$
.
ajax
({
url
:
"
http://localhost:3000/recommend/songs
"
,
xhrFields
:
{
withCredentials
:
true
},
success
:
function
(
data
)
{
console
.
log
(
data
)
},
error
:
function
(
err
)
{
console
.
log
(
err
)
}
})
},
error
:
function
(
err
)
{
console
.
log
(
err
)
}
})
</script>
</body>
</html>
\ No newline at end of file
axios
({
url
:
"
http://localhost:3000/login/cellphone?phone=YOUR_PHONE&password=YOUR_PASSWORD
"
}).
then
(
function
(
res
)
{
console
.
log
(
res
.
data
);
axios
({
url
:
"
http://localhost:3000/recommend/resource
"
,
withCredentials
:
true
//关键
}).
then
(
function
(
res
)
{
console
.
log
(
res
.
data
);
});
});
</script>
</body>
</html>
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录