如何从Webuntis API获取数据?

问题描述 投票:0回答:2

我有一个问题。我想使用 Webuntis API 并将考试日期放入 Google 日历中。现在我想学习如何使用 Webuntis API,但我只得到一个错误:

错误:登录失败。 {“jsonrpc”:“2.0”,“id”:“太棒了”,“错误”:{“消息”:“错误的凭据”,“代码”:-8504}}

我在 JavaScript 和 Python 中尝试过,两者都是相同的错误。

JavaScript:

const { WebUntis } = require('webuntis');

// Erstelle eine asynchrone Funktion, um 'await' verwenden zu können.
async function main() {
  const untis = new WebUntis('BK-Beckum', 'name', 'Password', 'tritone.webuntis.com');
  await untis.login();

  const timetable = await untis.getStudents();
  console.log(timetable);

  // Weitere asynchrone Aufrufe oder Operationen können hier stattfinden.
  await untis.logout()
}

// Rufe die asynchrone Funktion auf.
main();

Python:

import webuntis

s = webuntis.Session(
    username="EngelhCar",
    password="Password",
    server = "tritone.webuntis.com",
    school = "BK-Beckum",
    useragent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/115.0"
    )

s.login()
for klass in s.klassen():
    print(klass.name)
s.logout()

我尝试了不同的网址和不同的学校名称。我卸载了webuntis并重新安装了它。我尝试了其他功能或参数,但后来出现了其他错误。密码和用户名也正确,我只是编辑这篇文章的密码。

javascript python google-calendar-api
2个回答
0
投票

确保用户名和密码正确。 服务器和学校看起来不错。 只需将 useragent 更改为 useragent = "useragent" 即可。 然后它应该可以工作。


0
投票

我的邮递员请求适用于:

GET https://xxx.webuntis.com/WebUntis/jsonrpc.do?school={学校名称(url 编码)}

身体:

原始/JSON

{ “id”:2, “方法”:“验证”, “参数”:{ “用户”:“”, “密码”: ””, “客户”:“客户”, }, “jsonrpc”:“2.0” } (当使用任何代码 api 调用时,请确保对其进行字符串化,它不能作为 json 对象“{\”id\”:\“2\”,...}”发送)

有一个PDF Doc我用过,但很多东西可能已经过时了

© www.soinside.com 2019 - 2024. All rights reserved.