qq音乐搜索接口失效

384 阅读1分钟

在做vue音乐项目时候,发现qq音乐的搜索api无法访问: 'c.y.qq.com/soso/fcgi-b…' 已失效

解决:原替换为'c.y.qq.com/soso/fcgi-b…'

进行axios交互时候需要带额外参数

// 外部携带query和page参数
const data = {
      _: getRandomVal(),
      g_tk_new_20200303: 5381,
      w: query,  // 输入搜索
      p: page,   // 输入页数
      perpage: 20,
      n: 20,
      zhidaqu: 1,
      catZhida: true
      t: 0,
      flag: 1,
      ie: 'utf-8',
      sem: 1,
      aggr: 0,
      remoteplace: 'txt.mqq.all',
      uin: '0',
      needNewCode: 1,
      platform: 'h5',
      format: 'json'
    }
// 公共参数
const commonParams = {
  g_tk: token,
  loginUin: 0,
  hostUin: 0,
  inCharset: 'utf8',
  outCharset: 'utf-8',
  notice: 0,
  needNewCode: 0,
  format: 'json',
  platform: 'yqq.json'
}
// axios请求
 axios.get(url,{Object.assign({},commonParams,data)}).then((res)=>{
     console.log(res)
 })