我正在尝试使用其API创建Spotify应用,但我一直收到错误消息

时间:2020-04-14 22:49:44

标签: javascript spotify

我在控制台日志中不断收到错误消息,并且无法获取该日志来打印我想要的内容,这意味着它没有进入我的JavaScript文件的底部。错误消息会闪烁一秒钟,然后消失在控制台日志中。在它消失之前,我设法对其进行了屏幕截图,然后将照片放在下面。 Error Image

我不确定这是什么问题。访问网页时,我也收到错误消息“ INVALID_CLIENT:无效的客户端”,我也不确定。这是该网页的javascript。

let host = "https://accounts.spotify.com/authorize";
let client_id = "977f0f21630043c4ac83523663bc1779";
let redirect_uri = "http://www.bananafish.xyz/courses/csci240/elvis_pics.html";
let scope = "user-read-private user-read-email";
let response_type = "token";

let new_loc = host +
    "?client_id=" + encodeURIComponent(client_id) +
    "&redirect_uri=" + encodeURIComponent(redirect_uri) +
    "&scope=" + encodeURIComponent(scope) +
    "&response_type=" + response_type;


window.location = new_loc;

var hash = window.location.hash.substring(1);
var params = {};
hash.split('&').map(pair => {
    let temp = pair.split('=');
    params[temp[0]] = temp[1]
});

requirejs.config({
    baseUrl: '/javascript'
});
requirejs(["spotify-web-api2","https://d3js.org/d3.v5.min.js"], main);

function main(spotify, d3) {
    console.log("In the main function")
}

这是我拥有的小HTML;

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title> Spotify Web API </title>
    <link rel = "stylesheet"
          type = "text/css">
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
</head>
<body>
<script src="/javascript/require2.js" data-main="javascript/elvis_pics"></script>
</body>
</html>

0 个答案:

没有答案