TobiasFranek / webuntis

A API library that makes it easy to access the Webuntis JSON RPC 2.0 API
MIT License
28 stars 10 forks source link

WebUnits repository model is proteced #35

Closed Mastermori closed 6 years ago

Mastermori commented 6 years ago

When I try to log into my school with the admin and default user set to the same user (although it's not an admin, just setting the default doesn't work but thats an issue for another day) and then query the Period repository it gives me this: Webuntis\Repositories\Repository Object ( [model:protected] => Webuntis\Models\Students [instance:protected] => Webuntis\Webuntis Object ( [path:Webuntis\Webuntis:private] => https://stundenplan.hamburg.de/WebUntis/jsonrpc.do?school=Hh5868 [client:Webuntis\Webuntis:private] => Webuntis\Client\Client Object ( [requiredHttpHeaders:Datto\JsonRpc\Http\Client:private] => Array ( [Accept] => application/json [Content-Type] => application/json [Connection] => close ) [uri:Datto\JsonRpc\Http\Client:private] => https://stundenplan.hamburg.de/WebUntis/jsonrpc.do?school=Hh5868 [headers:Datto\JsonRpc\Http\Client:private] => Array ( [Accept] => application/json [Content-Type] => application/json [Connection] => close [Cookie] => JSESSIONID=39E33EE814222D158102EB94FF825492.nodeTC01; Path=/WebUntis; Version=1; Max-Age=1209600; Expires=Wed, 12-Sep-2018 08:37:05 GMT; ) [context:Datto\JsonRpc\Http\Client:private] => Resource id #20 [client:Datto\JsonRpc\Http\Client:private] => Datto\JsonRpc\Client Object ( [messages:Datto\JsonRpc\Client:private] => Array ( ) ) ) [currentUserId:Webuntis\Webuntis:private] => 224 [currentUserType:Webuntis\Webuntis:private] => 1 [context:Webuntis\Webuntis:private] => admin ) [cache:protected] => [executionHandler:protected] => Webuntis\Handler\ExecutionHandler Object ( [cache:Webuntis\Handler\ExecutionHandler:private] => ) ) So this suggest that I don't have access to the Periods which I know to be false because I can log in to the Web Untis mobile app with that exact data. Do I need to get an admin-read-only account from my school to get access to the Periods?

TobiasFranek commented 6 years ago

if you want the data from the request execute ->findAll() or other method. Please read the docs under Querys and then how to handle Repositories.

Mastermori commented 6 years ago

Thank you for the quick response but Uncaught Webuntis\Exceptions\ModelException: There is no Model available for the user type: "1" is what I get when I try to run the ->findAll() on the $query->get('Period') like this: print_r($query->get('Period')->findAll());

Mastermori commented 6 years ago

My config looks like this: $config = new WebuntisConfiguration([\n 'admin' => [\n 'server' => 'stundenplan.hamburg.de',\n 'school' => 'hh5868',\n 'username' => '???',\n 'password' => '???',\n 'path_scheme' => 'https://{server}/WebUntis/jsonrpc.do?school={school}'\n ],\n 'default' => [\n 'server' => 'stundenplan.hamburg.de',\n 'school' => 'hh5868',\n 'username' => '???',\n 'password' => '???',\n 'path_scheme' => 'https://{server}/WebUntis/jsonrpc.do?school={school}'\n ]\n ]); what might or might not be of interest is that the username starts with the number 1.

TobiasFranek commented 6 years ago

This is really strange, because the default UserTypes of the Webuntis Accounts are either 5 for teachers and 2 for students, do you log in with an different account?

TobiasFranek commented 6 years ago

and these types will be used to map the right model (Teacher Model, Student Model) to the User, because teachers and students have different endpoints

TobiasFranek commented 6 years ago

are your logged in with an klasse object?

Mastermori commented 6 years ago

No, I'm not, just the default config, I found another libary that works easier now, sorry for bothering you but keep up the good work ^^

TobiasFranek commented 6 years ago

yea this library is more for advanced usage, but I'm glad you found your fit.

TobiasFranek commented 6 years ago

will be solved in #37 #38 #39