SoFunction
Updated on 2025-04-07

Example of data acquisition of qq music api through backend interface proxy

Preface: Some QQ music API interfaces cannot be accessed directly through JSONP, and they need to be obtained through official agents, such as: lyrics, recommended playlists, etc.

1. Create an interface in:

// Start call:var express = require('express')
var axios = require('axios')
var app = express()
var apiRoutes = ()
('/api', apiRoutes)
 
 
// The last addition of devServer:  before(app) {
   ('/api/getDiscList', function (req, res) {
    var url = '/splcloud/fcgi-bin/fcg_get_diss_by_tag.fcg' // Original API    (url, {
     headers: {
      referer: '/',
      host: ''
     },
     params: 
    }).then((response) => {
     ()
    }).catch((e) => {
     (e)
    })
   })
  }

2. In the api js file, replace the url with the customized interface in step 1, and obtain the returned data through axios

import jsonp from 'common/js/jsonp'
import {commonParams, options} from './config'
import axios from 'axios'
 
 
export function getDiscList() {
 const url = '/api/getDiscList'
 
 
 const data = ({}, commonParams, {
  platform: 'yqq', // Add quotes  hostUin: 0,
  sin: 0,
  ein: 29,
  sortId: 5,
  needNewCode: 0,
  categoryId: 10000000,
  rnd: (),
  format: 'json'
 })
 
 
 return (url, {
  params: data
 }).then((res) => {
  return ()
 })
}

3. Get data through the method in the api's js file in the component

import {getDiscList} from 'api/recommend'
 
 
_getDiscList() {
 getDiscList().then((res) => {
  if ( === ERR_OK) {
   ('recommend:', res)
    = 
  } else {
   ('No, no recommendation')
  }
 })
}

The above example of obtaining data from QQ music API through back-end interface proxy is all the content I share with you. I hope you can give you a reference and I hope you can support me more.