Azərbaycan dili Bahasa Indonesia Bosanski Català Čeština Dansk Deutsch Eesti English Español Français Galego Hrvatski Italiano Latviešu Lietuvių Magyar Malti Mакедонски Nederlands Norsk Polski Português Português BR Românã Slovenčina Srpski Suomi Svenska Tiếng Việt Türkçe Ελληνικά Български Русский Українська Հայերեն ქართული ენა 中文
Subpage under development, new version coming soon!

Asunto: »news XML Data Improvements

2023-02-11 09:54:03
juytt para Terrion
I suspected that the Devs had not published anything :-)
Unfortunately I’m not « plus », so if you are able to publish public some notes it would be great.
Thanks.
2023-02-11 10:05:41
Terrion para juytt
Oh, I thought anyone could read it. Well, it's just a few lines:

------------

General:
/api/current: general info. about the team

Training:
/api/training/formations: training type for every position
/api/training/players: players who get general/advanced training. Also effectiveness and intensity

------------

To be able to use the api I had to send a POST to:

https://sokker.org//api/auth/login

With a json string in the body:

requestSettings.setRequestBody("{\"login\" : \"" + login + "\", \"password\" : \"" + password + "\", \"remember\" : false }");

------

The players URL limits the result to 20 players by default. I had to add the filter[limit] parameter:

/api/player?filter[limit]=200&filter[offset]=0&filter[team]=

------

Beware that the api returns different data if you access directly to a player or to the team. At least the "info.formation" is only shown in the player

------

Differences found between XML and JSON apis:

- Values and wages are returned in the users currency
- Weight and BMI are decimal numbers now, but I found a case where weight was an Integer
- Advanced training is no longer found in the api. I had to access /api/training/players to read to whole team
- Neither player or club's page show if the player is member of a NT
- I found no way to know if a player has a transfer ad
(editado)
2023-03-06 12:08:18
juytt para Terrion
thanks.

Trying to use api with php curl post i can log with your given RequestBody (well, in fact it's return NULL, so i suppose it's ok). But then when i try to GET something I've got an "error":"UNAUTHORIZED"

$data = array('login'=$login,'password'=$password,'remember'=False);
$url = "https://sokker.org/api/auth/login";

curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data) );
$result = curl_exec($ch);
echo ($result);

NULL

$url = "https://sokker.org/api/current";
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPGET, TRUE); // switch to GET
$result = curl_exec($ch);
echo $result;

"error":"UNAUTHORIZED"

Any idea ? Is there's a way to keep a session ? 'remember' should be True ?

Since i was trying few times and introduce bad request to test, i receive an "error":"6" when /auth/login. I suppose '6' means BAN USER (like xml), so i can't test anymore. Great.
2023-03-06 13:46:55
What headers you set in the login request?
2023-03-06 13:48:30
Anyway, check via browser what headers are sent on successful logging in.
2023-03-06 15:57:19
What headers you set in the login request?

This :

$data='{"login":"juytt","password":"---","remember":false}';

Then i set json header and post $data :

curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
curl_setopt($ch, CURLOPT_POSTFIELDS, $data );

Anyway, check via browser what headers are sent on successful logging in.

As I said I was getting NULL ( "{ }" in json). But since I'm only getting "error 6", I can't test successful login anymore...
(editado)
2023-03-06 17:00:47
Terrion para juytt
I get an empty response too. Maybe that 6 is the only problem now?
2023-03-06 17:36:50
Hi @jutt when you post on login nothing happens in response but that is fine
then you have to access the cookies and then you need to use that cookie in the header of the new post
in curl php you can use a cokkie file and then read the cookie from it
2023-03-06 17:40:08
something like this
curl_setopt ( $ch, CURLOPT_COOKIEJAR, $file_path );

and you need to get this value
PHPSESSID=xxxxxxxx
(editado)
2023-03-06 18:47:53
juytt para Terrion
Maybe that 6 is the only problem now?

Now yes, but it wasn't working too before 6. I did get the 'null' response, so the auth must have worked like you did, but then all my GET requests failed with a result: unauthorized.

So i suspect curl (in php) didn't keep auth alive for some reason. Maybe, like @sviktorov say, it needs a cookie (?) But it's weird, i didnt close the curl session handler so it should work without any cookie needs.
2023-03-06 19:28:03
Geston para juytt
You have to use cookiejar curl option for sure.

It should looks like:

//create, lets say variable which hold your cookie file path
$cookieFilePath = "../whatever/storage/this_is_my_cookie.txt";

//prepare options for curl connection
$options = array{
CURLOPT_URL => 'https://sokker.org/start.php?session=xml',
CURLOPT_POST => true,
CURLOPT_POSFIELDS => http_build_query($request->all()), // this is how I pass login and password from html form which was sent to my server with post request, possibly I was catching it somehow before to that variable from global REQUEST
CURLOPT_RETURNTRANSFER => true, // you need this to allow your server catch sokker server response
CURLOPT_HEADER => false, //you dont have to send any headers
CURLOPT_COOKIEJAR => $cookieFilePath, // here comes cookie!
);

$session = curl_init(); // init connection which returns session
curl_setopt_array($session, $options); // pass array with options here

$sokkerServerResponse = curl_exec($options); // this is how you log-in, but also everything else if you change url

curl_close($session); // close session

And thats all. You should have in $sokkerServerResponse something like "OK teamID=team_id"

This is for XML, but I think it should work for API aswell, whole cookie handling machanism.
2023-03-06 19:45:04
+1
2023-03-06 20:15:09
juytt para Geston
i will try cookie… when i ll be un-ban :-/

Thanks guys !
2023-03-07 10:05:12
juytt para juytt
It was cookie session. thanks.

i wonder if we can (re)use a cookie session for xml AND json api, or we need auth for both ?
2023-03-07 10:07:28
Can't. Different cookies, Different sessions.
2023-12-09 17:08:12
I didn't know where to post, but as this is a devs' corner...

On a given date, is there any way of finding the week and season of Sokker?