使用Linkedin代码登录会给我html验证错误

signin with Linkedin code give me html validation error

本文关键字:html 验证 错误 Linkedin 代码 登录 使用      更新时间:2023-09-26

我正在使用https://validator.w3.org验证我的HTML5网站。我使用的是Linkedin javascript登录SDK。我遵循了本教程https://developer.linkedin.com/docs/signin-with-linkedin

我收到这个错误

元素脚本的文本内容不是所需的格式:应为空格、制表符、换行符或斜杠,但找到的却是。

在这个代码块

<script type="text/javascript" src="//platform.linkedin.com/in.js">
  api_key: YOUR_API_KEY_HERE
  authorize: true
  onLoad: onLinkedInLoad
</script>

此代码的问题由教程提供。

我通过分离API的加载和API的启动来解决这个问题。

<script src="http://platform.linkedin.com/in.js?async=true"></script>
<script>
IN.init({
    api_key: 'YOUR_API_KEY_HERE',
    onLoad: onLinkedInLoad,
    authorize: true,
    scope: 'r_basicprofile r_fullprofile r_emailaddress r_contactinfo',
});
</script>

此代码是W3C 的有效代码