[Fixed] TM-WS does not work with PHP 5.2.x

Trackmania Forever public API and its open source PHP SDK.

Moderator: NADEO

User avatar
m4rcel
Posts: 650
Joined: 15 Jun 2010, 11:12
Contact:

[Fixed] TM-WS does not work with PHP 5.2.x

Post by m4rcel »

So after getting access to the TM WebServices (thanks for this :D), I of course tried to write a simple script, calling the NickName to a login. And I had to notice, that the SDK is currently not working under PHP 5.2.x (exactly 5.2.14), whereas the Requirements say "PHP 5.2 or newer".


In detail, I found the following errors/problems so far:
  • Fatal error: func_get_args(): Can't be used as a function parameter in /.../trackmania-ws.php on line 72 (and other lines)
    This error is caused due to using the func_get_args() as a parameter for another method call, and seems not to be possible as of PHP 5.2.
    Workaround:
    Replace all similar lines to

    Code: Select all

    return $this->executeGET('/tmf/players/%s/', func_get_args());
    with e.g.

    Code: Select all

    $params = get_func_args();
    return $this->executeGET('/tmf/players/%s/', $params);
  • Fatal error: Call to undefined function json_last_error() in /.../trackmania-ws.php on line 474
    json_last_error() has been introduced with PHP 5.3, and seems not to have any replacement in PHP 5.2 though. I think the only possibility on this point is to remove the error handling in case of PHP 5.2, and to only differentiate between "well formed JSON" and "malformed JSON" without any deeper debugging information.

It would be nice, if you can handle these errors to make the SDK compatible to PHP 5.2, rather than changing the requirements to PHP 5.3 ;)

FT»Marcel
ImageImage
Image
TheM
Posts: 1379
Joined: 15 Jun 2010, 14:30
Location: Uden, Noord-Brabant, Netherlands
Contact:

Re: TM-WS does not work with PHP 5.2.x

Post by TheM »

m4rcel wrote:It would be nice, if you can handle these errors to make the SDK compatible to PHP 5.2, rather than changing the requirements to PHP 5.3 ;)
Indeed, since most of the production servers (hosters) are still using 5.2 :|
Global moderator | Dutch moderator | Laddermoderator | ManiaWiki moderator
Server Manager/webmaster of Smurfen.net, join us on Canyon, Valley and Royal!
ESL (Game) Staff Head for TrackMania (Stadium, Canyon and Valley).
User avatar
gouxim
Nadeo
Nadeo
Posts: 1186
Joined: 14 Jun 2010, 17:20

Re: TM-WS does not work with PHP 5.2.x

Post by gouxim »

Thanks for the report. We indeed wanted to make à 5.2 SDK although all our codebase is 5.3. I'll update the SDK to make it compatible.
Please do not PM for support. Instead, create a thread so that everyone can contribute or benefit from the answer! 8-)
User avatar
gouxim
Nadeo
Nadeo
Posts: 1186
Joined: 14 Jun 2010, 17:20

Re: TM-WS does not work with PHP 5.2.x

Post by gouxim »

I fixed that in 0.3, should be working now. I left the json_last_error but with a function_exists check before.
Please do not PM for support. Instead, create a thread so that everyone can contribute or benefit from the answer! 8-)
User avatar
w1lla
Posts: 2287
Joined: 15 Jun 2010, 11:09
Location: Netherlands
Contact:

Re: TM-WS does not work with PHP 5.2.x

Post by w1lla »

It works. Thanks for the fix.

Preview can be found under:

http://tmrankings.com/intr/examples/test1.php
TM² Info
SM Info
QM Info

OS: Windows 10 x64 Professional
MB: MSI 970A-G46
Processor: AMD FX-6300 3500 mHz
RAM Memory: 16 GB DDR3
Video: SAPPHIRE DUAL-X R9 280X 3GB GDDR5
KB: Logitech G510s
Mouse: Logitech G300s
Mode Creation
ManiaScript Docs
User avatar
m4rcel
Posts: 650
Joined: 15 Jun 2010, 11:12
Contact:

Re: TM-WS does not work with PHP 5.2.x

Post by m4rcel »

Thanks for the update :)

I found another use of json_last_error() in line 493 ;)
ImageImage
Image
User avatar
gouxim
Nadeo
Nadeo
Posts: 1186
Joined: 14 Jun 2010, 17:20

Re: TM-WS does not work with PHP 5.2.x

Post by gouxim »

m4rcel wrote:I found another use of json_last_error() in line 493 ;)
gou1 wrote:I left the json_last_error but with a function_exists check before.
:geek:
Please do not PM for support. Instead, create a thread so that everyone can contribute or benefit from the answer! 8-)
User avatar
m4rcel
Posts: 650
Joined: 15 Jun 2010, 11:12
Contact:

Re: TM-WS does not work with PHP 5.2.x

Post by m4rcel »

Yes, that one occurence in line 474 has its function_exists() around, but the second occurence in line line 494 (within the if-statement) is missing this check and thus still producing a Fatal Error ;)
ImageImage
Image
User avatar
gouxim
Nadeo
Nadeo
Posts: 1186
Joined: 14 Jun 2010, 17:20

Re: TM-WS does not work with PHP 5.2.x

Post by gouxim »

m4rcel wrote:Yes, that one occurence in line 474 has its function_exists() around, but the second occurence in line line 494 (within the if-statement) is missing this check and thus still producing a Fatal Error ;)
Okay, I'm stupid :lol:
Thanks for the report, I'll update to 0.4 right away :geek:
Please do not PM for support. Instead, create a thread so that everyone can contribute or benefit from the answer! 8-)
User avatar
gouxim
Nadeo
Nadeo
Posts: 1186
Joined: 14 Jun 2010, 17:20

Re: TM-WS does not work with PHP 5.2.x

Post by gouxim »

SDK updated, it should work know :)
Please do not PM for support. Instead, create a thread so that everyone can contribute or benefit from the answer! 8-)
Post Reply

Return to “Trackmania Forever Web Services”

Who is online

Users browsing this forum: No registered users and 2 guests