mirror of
https://gitlab.com/Binaryify/neteasecloudmusicapi.git
synced 2025-05-23 22:37:41 +08:00
登录接口更新
This commit is contained in:
parent
15260bc154
commit
28da98d102
@ -416,6 +416,8 @@ $ sudo docker run -d -p 3000:3000 netease-music-api
|
||||
存结果的接口 , 可在请求 url 后面加一个时间戳参数使 url 不同 , 例子 :
|
||||
`/simi/playlist?id=347230×tamp=1503019930000` (之所以加入缓存机制是因为项目早期没有缓存机制,很多 issues 都是报 IP 高频,请按自己需求改造缓存中间件(app.js),源码不复杂)
|
||||
|
||||
!> 不要频繁调登录接口,不然可能会被风控,登录状态还存在就不要重复调登录接口
|
||||
|
||||
!> 如果是跨域请求 , 请在所有请求带上 `xhrFields: { withCredentials: true }` (axios 为 `withCredentials: true`, Fetch API 为 `fetch(url, { credentials: 'include' })`), 或直接手动传入 cookie (参见 `登录`), 否则
|
||||
可能会因为没带上 cookie 导致 301, 具体例子可看 `public/test.html`, 访问`http://localhost:3000/test.html`(默认端口的话) 例子使用 jQuery 和 axios
|
||||
|
||||
@ -439,6 +441,8 @@ $ sudo docker run -d -p 3000:3000 netease-music-api
|
||||
|
||||
说明 : 登录有三个接口,建议使用`encodeURIComponent`对密码编码或者使用`POST`请求,避免某些特殊字符无法解析,如`#`(`#`在 url 中会被识别为 hash,而不是 query)
|
||||
|
||||
不要频繁调登录接口,不然可能会被风控,登录状态还存在就不要重复调登录接口
|
||||
|
||||
#### 1. 手机登录
|
||||
|
||||
**必选参数 :**
|
||||
|
@ -4,6 +4,7 @@ const crypto = require('crypto')
|
||||
|
||||
module.exports = async (query, request) => {
|
||||
query.cookie.os = 'pc'
|
||||
query.cookie.appver = '2.9.7'
|
||||
const data = {
|
||||
username: query.email,
|
||||
password:
|
||||
@ -11,18 +12,13 @@ module.exports = async (query, request) => {
|
||||
crypto.createHash('md5').update(query.password).digest('hex'),
|
||||
rememberLogin: 'true',
|
||||
}
|
||||
let result = await request(
|
||||
'POST',
|
||||
`https://music.163.com/weapi/login`,
|
||||
data,
|
||||
{
|
||||
crypto: 'weapi',
|
||||
ua: 'pc',
|
||||
cookie: query.cookie,
|
||||
proxy: query.proxy,
|
||||
realIP: query.realIP,
|
||||
},
|
||||
)
|
||||
let result = await request('POST', `https://music.163.com/api/login`, data, {
|
||||
crypto: 'weapi',
|
||||
ua: 'pc',
|
||||
cookie: query.cookie,
|
||||
proxy: query.proxy,
|
||||
realIP: query.realIP,
|
||||
})
|
||||
if (result.body.code === 502) {
|
||||
return {
|
||||
status: 200,
|
||||
|
@ -4,6 +4,7 @@ const crypto = require('crypto')
|
||||
|
||||
module.exports = async (query, request) => {
|
||||
query.cookie.os = 'pc'
|
||||
query.cookie.appver = '2.9.7'
|
||||
const data = {
|
||||
phone: query.phone,
|
||||
countrycode: query.countrycode || '86',
|
||||
@ -16,7 +17,7 @@ module.exports = async (query, request) => {
|
||||
}
|
||||
let result = await request(
|
||||
'POST',
|
||||
`https://music.163.com/weapi/login/cellphone`,
|
||||
`https://music.163.com/api/login/cellphone`,
|
||||
data,
|
||||
{
|
||||
crypto: 'weapi',
|
||||
|
Loading…
x
Reference in New Issue
Block a user