Subpage under development, new version coming soon!
Asunto: »news XML Data Improvements
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.
Unfortunately I’m not « plus », so if you are able to publish public some notes it would be great.
Thanks.
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)
------------
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)
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.
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.
kryminator para
juytt
Anyway, check via browser what headers are sent on successful logging in.
juytt para
kryminator
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)
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)
I get an empty response too. Maybe that 6 is the only problem now?
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
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
something like this
curl_setopt ( $ch, CURLOPT_COOKIEJAR, $file_path );
and you need to get this value
PHPSESSID=xxxxxxxx
(editado)
curl_setopt ( $ch, CURLOPT_COOKIEJAR, $file_path );
and you need to get this value
PHPSESSID=xxxxxxxx
(editado)
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.
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.
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.
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.
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 ?
i wonder if we can (re)use a cookie session for xml AND json api, or we need auth for both ?
juytt para
kryminator
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?
On a given date, is there any way of finding the week and season of Sokker?